Results 1 to 4 of 4
Thread: Help with stack
- 04-10-2012, 01:19 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Help with stack
ok so i have this coordinate class and i have some of them pushed onto a stack. now what i want to do is peek() at one of them and be able to use the getRow and getColumn method at the one i peek at. How do i do this? The problem i am having is i am creating a new instance of Coordinate and then assigning stack.peek() to it and then using the methods on it but that not working. ConfusedJava Code:public class Coordinate{ private Integer row; private Integer column; public Coordinate(Integer row, Integer column){ this.row = row; this.column = column; } public void setRow(Integer row){ this.row = row; } public void setColumn(Integer column){ this.column = column; } public Integer getRow(){ return row; } public Integer getColumn(){ return column; } public String toString(){ return "<" + row.toString() + "," + column.toString() + ">"; } }
- 04-10-2012, 01:46 AM #2
Re: Help with stack
Please explain what is not working.that not working.
I don't see where you are calling the peek() method.If you don't understand my response, don't ignore it, ask a question.
- 04-10-2012, 01:51 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
Re: Help with stack
it gives me this; incompatible typesJava Code:Coordinate coordinate = stack.peek();
Coordinate coordinate = mazeStack.peek();
^
required: Coordinate
found: Object
1 error
- 04-10-2012, 01:59 AM #4
Similar Threads
-
Stack problem. Object array pushed into stack came out different.
By LoViNgHeArTy in forum New To JavaReplies: 2Last Post: 01-14-2012, 08:56 PM -
need stack help
By ali1 in forum New To JavaReplies: 4Last Post: 11-05-2011, 08:48 PM -
stack program
By pinkx in forum New To JavaReplies: 22Last Post: 08-26-2011, 08:55 PM -
Stack
By kayln in forum EclipseReplies: 0Last Post: 03-04-2011, 08:14 PM -
How big is the stack??
By mgeno216 in forum New To JavaReplies: 6Last Post: 03-04-2011, 08:04 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks