This is what I have:
public class prob_1{
public static void main(String[] args){
prob_1.ListNode L = new prob_1.ListNode(args[0]); ----error
for(int loop=0; loop < args.length; loop++){
L.setNext(new prob_1.ListNode(args[loop])); ------error
}//End loop
}//End main
public class Listnode {
//*** fields ***
private Object data;
private Listnode next;
//*** methods ***
// 2 constructors
public Listnode(Object d) {
this(d, null);
}
public Listnode(Object d, Listnode n) {
data = d;
next = n;
}
// access to fields
public Object getData() {
return data;
}
public Listnode getNext() {
return next;
}
// modify fields
public void setData(Object ob) {
data = ob;
}
public void setNext(Listnode n) {
next = n;
}
}
I have to have a linked list class and my main program in one java file. The two places where im getting errors are pointed out above.
I'm probably doing something stupid so I would appreciate it if someone told me what it is.
thanks.
Linked ListLinked List implementation in a class
Page 1 of 1
3 Replies - 8136 Views - Last Post: 07 September 2005 - 02:43 AM
Replies To: Linked List
#3
Re: Linked List
Posted 24 August 2005 - 07:59 AM
prob_1.java:8: cannot resolve symbol
symbol: class ListNode
location: class prob_1
>> prob_1.<<ListNode L = new prob_1.ListNode(args[0]);
prob_1.java:8: cannot resolve symbol
symbol: class ListNode
location: classs prob_1
prob_1.ListNode L = new >>prob_1.<<ListNode(args[0]);
prob_1. java:12: cannot resolve symbol
symbol: class ListNode
location: class prob_1
L.setNext(new >>prob_1.<<ListNode(args[loop]));
Im not sure how to put the linked list class in my prob_1 main program class and then how to use the linked list.
symbol: class ListNode
location: class prob_1
>> prob_1.<<ListNode L = new prob_1.ListNode(args[0]);
prob_1.java:8: cannot resolve symbol
symbol: class ListNode
location: classs prob_1
prob_1.ListNode L = new >>prob_1.<<ListNode(args[0]);
prob_1. java:12: cannot resolve symbol
symbol: class ListNode
location: class prob_1
L.setNext(new >>prob_1.<<ListNode(args[loop]));
Im not sure how to put the linked list class in my prob_1 main program class and then how to use the linked list.
#4
Re: Linked List
Posted 07 September 2005 - 02:43 AM
I've just spotted a typo in your code:
You declared as:
public class Listnode ...
But you reference it as:
prob_1.ListNode ...
Java is case sensitive. Also I think you can simply write Listnode in prob_1 as it is within its scope. So I assume you can simply write:
Listnode L = new .Listnode(args[0]);
I hope it helps.
You declared as:
public class Listnode ...
But you reference it as:
prob_1.ListNode ...
Java is case sensitive. Also I think you can simply write Listnode in prob_1 as it is within its scope. So I assume you can simply write:
Listnode L = new .Listnode(args[0]);
I hope it helps.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|