Skip to content

Instantly share code, notes, and snippets.

@Rahandi
Last active October 12, 2017 18:00
Show Gist options
  • Save Rahandi/fa91c6f325b9d021ea837faef3ac8b25 to your computer and use it in GitHub Desktop.
Save Rahandi/fa91c6f325b9d021ea837faef3ac8b25 to your computer and use it in GitHub Desktop.
Overloading
public class MainClass {
public static void main(String[] args){
MyClass t = new MyClass(0);
t.info();
t.info("Overloaded method");
new MyClass();
}
}
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