I just happened to read abt vectors in java..For some practice,I implemented this small script where I Store objects in a vector..Then,I want to invoke the methods of the corresponding objects.My problem is that in this line
System.out.prin tln(vc.elementA t(i).test3());
the test3() method of my object is being underlined..I know I am retrieving an abject from vc.elementAt(i) ,then why is the method test3() being underlined??
System.out.prin tln(vc.elementA t(i).test3());
the test3() method of my object is being underlined..I know I am retrieving an abject from vc.elementAt(i) ,then why is the method test3() being underlined??
Code:
import java.util.*;
public class MITlab2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
test_vector1();
}
public static void test_vector1(){
test_class vm=new test_class();
Vector vc=new Vector();
vc.add(vm);vc.add(vm);vc.add(vm);
System.out.println(vc.size());
for (int i=0;i<vc.size();i++){
System.out.println(vc.elementAt(i).test3());
}
}
}
class test_class{
public String vim="testing";
public boolean test3(){
return true;
}
}
Comment