Last active
October 12, 2017 18:00
-
-
Save Rahandi/fa91c6f325b9d021ea837faef3ac8b25 to your computer and use it in GitHub Desktop.
Overloading
This file contains 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 MainClass { | |
public static void main(String[] args){ | |
MyClass t = new MyClass(0); | |
t.info(); | |
t.info("Overloaded method"); | |
new MyClass(); | |
} | |
} |
This file contains 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
class MyClass { | |
int height; | |
MyClass(){ | |
System.out.println("bricks"); | |
height = 0; | |
} | |
MyClass(int i){ | |
System.out.println("Building new House that is " + i + " feet tall"); | |
height = i; | |
} | |
void info(){ | |
System.out.println("House is " + height + " feet tall"); | |
} | |
void info(String s){ | |
System.out.println(s + ": House is " + height + " feet tall"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment