File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes arrayList access to Object's instance variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "arrayList access to Object Watch "arrayList access to Object New topic
Author

arrayList access to Object's instance variables

kavundamani senthil
Greenhorn

Joined: Feb 28, 2008
Posts: 16
In the program below how can i access the fields bankName, accId from the object o ?

import java.util.*;
public class sorting {
String bankName ;
int accId;
public void addaccount(String bankName,int accId)
{
this.bankName = bankName;
this.accId = accId;
}
public static void main(String args[])
{
TreeSet t = new TreeSet();
sorting s = new sorting();
sorting s1 = new sorting();
s.addaccount("IndianBank",100);
s1.addaccount("IndianBank",99);
t.add(s);
t.add(s1);
Iterator it = t.iterator();
while(it.hasNext())
{
object o = it.next();}
}
}
Paul Somnath
Ranch Hand

Joined: May 19, 2008
Posts: 177


Preparing for SCJP 6.0
 
 
subject: arrayList access to Object's instance variables