INNER CLASS ABSTRACTION IN JAVA
INNER CLASS METHOD CREATION:
public
class InnerClas
{
static
private int i=1;
static
class Innner
{
public
void getval()
{
System.out.println("value
of i.."+i);
}
}
public
static void main(String args[])
{
Innner
i1=new Innner();
i1.getval();
}
}
Sample code: From Outer class calling Inner class method
public
class Outerclass
{
private
int i=8;
public
void createInner()
{
Innerclass
i1=new Innerclass();
i1.getvalue();
}
class
Innerclass
{
public
void getvalue()
{
System.out.println("value
of i.."+i);
}
}
}
class
Invoke
{
public
static void main(String args[])
{
Outerclass
outerobj=new Outerclass();
Outerclass.Innerclass
innerobj= outerobj.new Innerclass();
innerobj.getvalue();
}
}
No comments:
Post a Comment