Results 1 to 7 of 7
Thread: Need help please
- 08-08-2010, 08:28 PM #1
Member
- Join Date
- Aug 2010
- Posts
- 4
- Rep Power
- 0
Need help please
I am testing a queue and im trying to insert a number onto the queue but i keep getting an error message saying - <identifier> expected. Anyone know how i can fix this so that i can output the number i want to add onto my queue. Any help will be much appreciated. Here is the code:
public class NewArray
{
ArrayPriorityQueue myarray = new ArrayPriorityQueue(5);
public void myprogobj();
System.out.println(myarray.enqueue(4)); (<identifier> expected)
}
- 08-08-2010, 08:30 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 08-08-2010, 08:35 PM #3
Member
- Join Date
- Aug 2010
- Posts
- 4
- Rep Power
- 0
- 08-08-2010, 08:43 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 08-08-2010, 08:55 PM #5
Member
- Join Date
- Aug 2010
- Posts
- 4
- Rep Power
- 0
- 08-08-2010, 09:37 PM #6
Member
- Join Date
- Aug 2010
- Posts
- 4
- Rep Power
- 0
Ok this is what i have now:
public class NewArray
{
public void myprogobj()
{
ArrayPriorityQueue myarray = new ArrayPriorityQueue(5);
myarray.enQueue(4);
myarray.enQueue(3);
}
public static void main (String args[]){
System.out.println(myarray);
}
}
But the problem is i cant get it to output anything and an error is produced saying that it cannot find symbol - variable myarray where i have put System.out.prinln(myarray);
- 08-08-2010, 10:33 PM #7
Its a scope problem. There is no variable myarray that is in scope for the main() method.
myarray is a local variable in the myprogobj method.
You need to move its definition outside of any methods so all methods can see it.
Your next problem will be trying to access a non-static variable from a static context.


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks