- 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); }
- Create a new main method.
public static void main(String[] args){ int hour = 11; int minute = 59; printTime(hour, minute); }
- 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); } }
- Compile and then run the program. You should see the following output.
11:59