Anonymous class Example : What's wrong with my code?? :(
package test;
public class Anonymous{
public class Popcorn{
public void pop(){
System.out.println("Popcorn pops");
}
}
public static void main(String args[]){
Popcorn p = new Popcorn(){
public void pop(){
System.out.println("Cooks popcorn");
}
};
p.pop();
}
}
Re: Anonymous class Example : What's wrong with my code?? :(
Quote:
What's wrong with my code?
It's not properly formatted for displaying on the forum
Please Edit your post and wrap your code with
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
If you are getting errors, please copy and paste the full text here.
Re: Anonymous class Example : What's wrong with my code?? :(
Code java:
<
package test;
public class Anonymous{
public class Popcorn{
public void pop(){
System.out.println("Popcorn pops");
}
}
public static void main(String args[]){
Popcorn p = new Popcorn(){
public void pop(){
System.out.println("Cooks popcorn");
}
};
p.pop();
}
}
>
Re: Anonymous class Example : What's wrong with my code?? :(
What happened to the indentation formatting of the code? All the statements start in column one. There should be indentation of source lines for each level of nesting of the logic. For example:
Code :
public void pop(){
System.out.println("Popcorn pops");
}
If you are getting errors, please copy and paste the full text here.