Recall from lecture: A Java program must be compiled, or translated into binary instructions. Then it can be executed or run. When you run a program, it displays output messages to the user in a text window called a console.
For this exercise, let's compile and run a short program that we will provide to you. (See the following slides.) If you get stuck, ask a classmate or TA for help.
continued on next slide...
public class MyFirstProgram { public static void main(String[] args) { System.out.println("Hello, world!"); System.out.println(); System.out.println("This is my very first program."); System.out.println("Hooray!"); } }
continued on next slide...
.java
and must match the 'public
class' name from the Java program. Name this
file MyFirstProgram.java
.
continued on next slide...
continued on next slide...