Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Daisy Brown   on Oct 13 In Java Category.

  
Question Answered By: Latoya Murray   on Oct 13

Yes it is possible, but you have to cast the return value:

Worker worker = (Worker)workers.elementAt(i);
int salary = worker.getSalary();

Or you could start using Java 1.5, which has generics:

Vector<Worker> workers = new Vector<Worker>;
workers.add(worker);
...
int salary = workers.elementAt(i).getSalaray();

Share: