CH4 – Parameters and Arguments

  1. Create a new file named PrintTwice.java and add the following code to the file.
public class PrintTwice {
 public static void printTwice(String s) {
   System.out.println(s);
 }
 public static void main(String[] args) {
   printTwice("Don't make me say this twice!");
   printTwice("Don't make me say this twice!");
 }
}
  1. Compile and run the program.
javac PrintTwice.java
java PrintTwice
Don't make me say this twice!
Don't make me say this twice!