Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi! I just don't get it. I have 1

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi!

I just don't get it. I have three nested for-loops and the counter-variables for these loops are definied globally. The if-statement in the third for-loop does not recognize the variables "i" and "e"... WHY?

Code:
 	for( i = 0; i < oldVec.size(); i++ )
 	{
 		for( e = 0; e < newVec.size(); e++ )
 		{
 			equal = 0;
 			for( x = 0; x < ((Vector)newVec.elementAt(e)).size(); x++ )
 			{
 				if( oldVec.elementAt(i).elementAt(x) == newVec.elementAt(e).elementAt(x) ){
 					equal++;
 				}
 			}
			if( equal == 3 ) isDuplicate = true;
 		}
 		if( !isDuplicate )
 		newVec.add(oldVec.elementAt(i));
 	}

And this is the error message from javac:

Code:
ReloadScheduleObj.java:50: cannot resolve symbol
symbol  : method elementAt (int)
location: class java.lang.Object
                                if( oldVec.elementAt(i).elementAt(x) == newVec.elementAt(e).elementAt(x) ){
                                                    ^
ReloadScheduleObj.java:50: cannot resolve symbol
symbol  : method elementAt (int)
location: class java.lang.Object
                                if( oldVec.elementAt(i).elementAt(x) == newVec.elementAt(e).elementAt(x) ){


Any help is appreciated!

Cheers

frag

patrick.metz@epost.de
 
The method elementAt of Vector returns an Object therefore you must cast it back to a Vector to be able to execute the second elementAt().

IE:

( (Vector)(oldVec.elementAt(i)) ).elementAt(k)
 
Of course! *slappingmyself* Thanx dude! ;)

patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top