This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: arrayList access to Object's instance variables
 
Similar Threads
Treeset throwing ClassCastException
ClassCast Exception while using TreeSet
TreeXxx VS PriorityQueue
treeset doesnt take any parameters?
Doubt in Comparable interface