class Nested
{
int a,b,c;
double s,ar;
public void getdata()
{
a = 2;
b = 3;
c = 4;
}
public double semiperimeter() //semiperimeter( ) is the nested method of area( )
{
double t = (a+b+c)/2;
return(t);
}
public void area()
{
s = semiperimeter();
ar = Math.sqrt(s*(s-a)*(s-b)*(s-c));
}
void display()
{
System.out.println("Area of triangle"+ar);
}
public static void main()
{
Nested ob = new Nested();
ob.getdata();
ob.area();
ob.display();
}
}
in above code why we called the function semiperimeter( ) through area( ) and with in area( )? .what is the benefit of nested member methods? A member function can be called by using its name inside another member function of the same class for that you do not need an object & directly without using the dot operator? why???? but to call the non static method we uses Objectname.functionname(); but in s = semiperimeter(); we are not using object and . operator?? why??