• Source
    1. class MyClass {
    2. int height;
    3. MyClass() {
    4. System.out.println("bricks");
    5. height = 0;
    6. }
    7. MyClass(int i) {
    8. System.out.println("Building new House that is "
    9. + i + " feet tall");
    10. height = i;
    11. }
    12. void info() {
    13. System.out.println("House is " + height
    14. + " feet tall");
    15. }
    16. void info(String s) {
    17. System.out.println(s + ": House is "
    18. + height + " feet tall");
    19. }
    20. }
    21. public class MainClass {
    22. public static void main(String[] args) {
    23. MyClass t = new MyClass(0);
    24. t.info();
    25. t.info("overloaded method");
    26. //Overloaded constructor:
    27. new MyClass();
    28. }
    29. }