CallingMethodsInSameClass.java 445B

12345678910111213141516171819202122232425
  1. /* CallingMethodsInSameClass.java
  2. *
  3. * illustrates how to call static methods a class
  4. * from a method in the same class
  5. */
  6. public class CallingMethodsInSameClass
  7. {
  8. public static void main(String[] args) {
  9. // Don't choose this one either. :-)
  10. printOne();
  11. printOne();
  12. printTwo();
  13. }
  14. public static void printOne() {
  15. System.out.println("Hello World");
  16. }
  17. public static void printTwo() {
  18. printOne();
  19. printOne();
  20. }
  21. }