Re: java class hierarchy
- From: Joshua Cranmer <Pidgeot18@xxxxxxxxxxx>
- Date: Sat, 21 Jul 2007 17:05:16 GMT
On Sat, 21 Jul 2007 18:43:24 +0200, Thomas wrote:
In the main loop I have to keep the refrence to the object taken from
FIFO, and here is the problem : what type of refrence it should be ? Not
a symbol because it is abstract, but it implements the Evaluate
interface. I confused. Any suggestions, please ?
What do you mean, "Not a symbol because it is abstract"? Any type can be
used for reference, including abstract classes and interfaces. This would
be partial code for what I think you want to do:
LinkedList<Symbol> stack = new LinkedList<Symbol>();
Queue<Symbol> queue = new LinkedList<Symbol>();
// ... Fill queue ...
while (!queue.isEmpty()) {
Symbol head = queue.remove();
if (head instanceof Operand) {
stack.addLast(head);
} else if (head instanceof Function) {
// ... manipulate stack, etc.
}
}
.
- References:
- java class hierarchy
- From: Thomas
- java class hierarchy
- Prev by Date: Re: Java and avoiding software piracy?
- Next by Date: Re: Java and avoiding software piracy?
- Previous by thread: java class hierarchy
- Next by thread: Re: java class hierarchy
- Index(es):