I am a beginner in Java and I have tried to implement a tail and I've made all the others methods, but at the toString() method, the program won't work. Here's my attempt:
class Tail {
int n;
Node prim;
Node last;
class Node {
Node next;
int info;
}
Tail() {
prim = null;
last = null;
n = 0;
}
public String toString() {
StringBuilder s = new StringBuilder();
for (int info : this)
s.append(info + " ");
return s.toString();
//return this.info.toString();
}
It gives an error if I try to return this.info.toString() . I would appreciate any advice or solution for solving this problem, thanks