I found the following Java class:
public class MiClase {
int informacion;
MiClase siguiente;
public MiClase(int valor) {
informacion = valor;
siguiente = null;
}
}
There are native types in Java such as int and String. But in this class that I found, the author is creating a new type: MyClass , which is the name of the class.
In this place they ask the same as me, but in the answers they give, they talk about instantiating objects, and that is not what the question refers to.
Can you please help me understand this? Please, I'm new to Java, so I would absolutely appreciate if you could answer so I can understand.
Reformulate the question (but leaving the 1st formulation to see the changes)
The original class is this:
public class Nodo {
int informacion;
Nodo siguiente;
public Nodo(int valor) {
informacion = valor;
siguiente = null;
}
}
Around 9:00 minutes of this video tutorial is where I took the class, and there you can see how the stack type lists work. Now that I review the video again, the author does not refer to following as a variable, but as an object.
This completely changes the doubt and the question. Because I understand that normally objects are created like this: Next node = new Node (); But in the video it turns out that an object can be created just like a variable is declared: Next node; But then I do not understand anything anymore, because the Node class is supposed to have 2 attributes: information and following . But how can one of its attributes be an instantiated object of the same class?
Please excuse me for raising my doubts incorrectly, generally and even superficially. But I have tried to find answers, and I have not yet succeeded. That is why I have forced myself to ask for your help so that they can throw a little light on me. Thanks.