Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Array required but vector found error: please help

807603Dec 24 2007 — edited Dec 24 2007
Hi there. I'm trying to make a vector of pointers to Objects. I'm using vectors as opposed to arrays becuase i don't know how many objects I'm going to have.

this is all within the same java file:
class World
{
...
Vector objects = new Vector();
...
ShadeRec hit( Ray ray){
		int num_objects = objects.size();
		
		for (int j = 0; j<num_objects; j++){
			if (objects[j].hit(ray,t,sr) && (t<tmin)){
				sr.hit_an_object = true;
				tmin = t;
				sr.colour = objects[j].get_colour();
			}
		}
		return sr;
	}
Im getting errors for "objects[j]" (in both occurances) that say "Array required, but java.Util.Vector found".

I don't understand why it's saying this as "objects" is a vector so why does it need an array??
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 21 2008
Added on Dec 24 2007
7 comments
883 views