Nesting of Methods in java

Nesting of Methods:

A method of a class can be called only by an object of that class using the dot operator. So, there is an exception to this. A method can be called by using only its name by another method of the same class which is called Nesting of Methods.

Program:

class test
{
int a,b;
test(int p, int q)
{
a=p;
b=q;
}
int greatest()
{
if(a>=b)
return(a);
else
return(b);
}
void display()
{
int great=greatest();
System.out.println("The Greatest Value="+great);
}
}
class temp
{
public static void main(String args[])
{
test t1=new test(25,24);
t1.display();
}
}

Output:
The Greatest Value= 25