Spaces:
Running
Running
| Write two methods: printHey() and printBye() | |
| The methods print either the string "Hey!" or the string "Bye!" according to their name. | |
| See an example below: | |
| public static void main(String[] args) { | |
| printHey(); | |
| printBye(); | |
| } | |
| Program outputs: | |
| Hey! | |
| Bye! | |
| import java.util.Random; | |
| public class Test{ | |
| public static void main(String[] args){ | |
| final Random r = new Random(); | |
| System.out.println("Testing printHey:"); | |
| printHey(); | |
| System.out.println(""); | |
| System.out.println("Testing printBye:"); | |
| printBye(); | |
| } | |
| public static void printHey(){ | |
| System.out.println("Hey!"); | |
| } | |
| public static void printBye(){ | |
| System.out.println("Bye!"); | |
| } | |
| } | |
| Testing printHey: | |
| Hey! | |
| Testing printBye: | |
| Bye! | |