Created
May 31, 2017 05:58
-
-
Save pethaniakshay/257de9740888ddcf8816c2e382afb692 to your computer and use it in GitHub Desktop.
Example of Anonymous Object In Java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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