This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Java in General and the fly likes Please explain output of mention source code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Please explain output of mention source code" Watch "Please explain output of mention source code" New topic
Author

Please explain output of mention source code

Kaustubh G Sharma
Ranch Hand

Joined: May 13, 2010
Posts: 1270

public abstract class MyClass {

public void test() {
System.out.println("Howdy");

}

public static void main(String[] args) {
MyClass m = new MyClass() {
};

m.test();
}

}

Output: Howdy

Please explain it. Thanks



No Kaustubh No Fun, Know Kaustubh Know Fun..
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
You are creating an anonymous class which is a subclass of that abstract class.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38509
    
  23
Java Language Specification link about anonymous classes.
Tyson Lindner
Ranch Hand

Joined: May 16, 2012
Posts: 172
So many tricky java problems. I didn't catch the brackets after "new MyClass()" at first.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please explain output of mention source code