CH4 – Stack Diagrams

  1. Use your preferred editor to create a new class named PrintTime. Add the following method to the class.
public static void printTime(int hour, int minute){
  System.out.print(hour);
  System.out.print(":");
  System.out.println(minute);
}
  1. Create a new main method.
public static void main(String[] args){
  int hour = 11;
  int minute = 59;
  printTime(hour, minute);
}
  1. The final class should appear as follows.
public class PrintTime {
  public static void printTime(int hour, int minute){
    System.out.print(hour);
    System.out.print(":");
    System.out.println(minute);
  }
  public static void main(String[] args){
    int hour = 11;
    int minute = 59;
    printTime(hour, minute);
  }
}
  1. Compile and then run the program. You should see the following output.
11:59