public class Demo
{
public void met(Object d)
{
class my {
public String Work(String s){
return s+",JAVA";
}
}
d=new my().Work("Hello");//statement 1
System.out.println(d);//statement 2
}
public static void main(String args[])
{
new Demo().met(new Object());
}
}
I don't know it's asked before or not. Here in this class Demo
I am creating class my
.
When I put statement 1 and 2 before class it gives me error but when I put it after class that's okay.
So it means when I call method, class is loaded and class file is created named Demo$1my.class
so that if I put statement 1 and 2 after class it works. Is it So?
My Question is can I create object of my
class from main method and How?