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