aspose file tools
The moose likes Beginning Java and the fly likes toString Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "toString" Watch "toString" New topic
Author

toString

Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 74
I'm trying to make a toString to display my stack but i'm getting incompatible types. its the method starting on 106.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

should line 108 be



(missing the parens)


Never ascribe to malice that which can be adequately explained by stupidity.
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 74
I sure do feel silly now thank you
Dustin Schreader
Ranch Hand

Joined: May 25, 2009
Posts: 74
although When it prints out in gui it only prints out 1 item of the stack what I would like it to do is keep printing out the entire stack such as
4
3
2
n
t
So you can see every element in the stack, this is what i'm using in my gui to print it out at the moment.

outputStackTF.setText(myStack.toString());
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10043
    
    6

I've just barely skimmed your code, so i may not be correct. But it looks to me like in your public String toString() method, you are only calling the toString() method on the top element...therefore, it only prints what is in the top element.

What you would need to do is write some code that reads each element in the stack and calls IT'S toString() method.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: toString
 
Similar Threads
get variable info from subclass
reverse for stacks??
Linked List
Gui calling method
Generics: cannot make a static reference to the non-static type