How can I get a specific value from an object?
I'm trying to get a value of an instance
for eg.
ListOfPpl newListOfPpl = new ListOfPpl(id, name, age);
Object item = newListOfPpl;
How can I get a value of name from an Object item??
Even if it is easy or does not interest you can anyone help me??
Edited: I was trying to build a binary tree contains the node of ListOfPpl, and need to sort it in the lexicographic. Here's my code for insertion on the node. Any clue??
public void insert(Object item){
Node current = root;
Node follow = null;
if(!isEmpty()){
root = new Node(item, null, null);
return;
}boolean left = false, right = false;
while(current != null){
follow = current;
left = false;
right = false;
//I need to compare and sort it
if(item.compareTo(current.getFighter()) < 0){
current = current.getLeft();
left = true;
}else {
current = current.getRight();
right = true;
}
}if(left)
follow.setLeft(new Node(item, null, null));
else
follow.setRight(new Node(item, null, null));
}