A variable in java can have a name and a type. A type can possibly be a primitive type or a user define type. The one that you declared
public hello n;
is a variable of user defined type hello. In java, you can create your own type by creating a class (there are some advance stuff like adt,etc) but the basic way is using a class. Now, creating a variable of user defined type is called as creating an object of the class. Once, you create an object, you can give it all the functionality you want by listing them in the class.
By creating the object of same class within a class, you are saying that I was an instance of "hello" type in hello itself. This stuff is more useful while creating data structures like linkedlist. for example,
In a linkedlist, you can define a node of the linkedlist as
public class LinkedNode<E> {
<E> data;
LinkedNode next;
}
See, I just created same stuff as you did with hello n. Here, you are saying that the object of type LinkedNode should have two things- a data and a reference to the next node. Same is the case with your code, creating a field of type hello, you are saying that any instance of type hello should have an hello object in it.
You can add methods and other functionality to the class as well.
hellonamedn.n, of typehello. You can make a newhelloobject, and inside thathelloobject, it can set anotherhelloobject.a class name that's used to declare a variable?what do you mean? you always need the class name to declare a variable.