Hi,
I'm trying to compile a simple program but I can't due to one error. The program is the following:
import java.io.*;
class Nodo
{
private Object elemento;
private Nodo top,aux,fin;
public Nodo()
{
Nodo n=new Nodo();
n.elemento=null;
n.top=null;
n.fin=null;
n.aux=null;
}
public void push(Object e)
{
Nodo temp=new Nodo();
temp.elemento=e;
if (n.top==null)
{
n.top=n;
n.aux=n;
}
if (n.top!=null)
{
temp.elemento=e;
temp.fin=top;
top=temp;
}
}
public static void main(
String args[])
{
Nodo nuevo=new Nodo();
nuevo.push(1);
}
}
After compiling the program I can display the following error:
Undefined variable or class name: n
This error appears me in the Push function and I don't know how to solve it.
Any ideas?
Thanks.