Skip to content

Instantly share code, notes, and snippets.

@pethaniakshay
Created May 31, 2017 05:58
Show Gist options
  • Save pethaniakshay/257de9740888ddcf8816c2e382afb692 to your computer and use it in GitHub Desktop.
Save pethaniakshay/257de9740888ddcf8816c2e382afb692 to your computer and use it in GitHub Desktop.
Example of Anonymous Object In Java
public class AnonymousObject{
public static void main(String args[]){
System.out.println("Addtion: " + new Calc().add(5,9));
System.out.println("Multiplication: " + new Calc().mul(3,5));
}
}
class Calc{
public int add(int n1, int n2){
return n1 + n2;
}
public int mul(int n1, int n2){
return n1 * n2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment