• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

arrayList access to Object's instance variables

 
kavundamani senthil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 177
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic