0/30 Days Completed 0 Learning Days
Day 1 of 30 · Week 1 — Java Foundations
What is Java? Your first program
1 Learn
Java is a programming language: a way of writing instructions that a computer can follow. Java code is written in files ending with .java.
Every Java program lives inside a class. To run it as an application, Java looks for a special method called main — this is the starting point.
System.out.println() prints a line of text on the screen. It is the easiest way to see what your program is doing.
2 See the Code
Java
public class Hello {
public static void main(String[] args) {
System.out.println("Hello, Java!");
System.out.println("Day 1 done.");
}
}- public class Hello — creates a class named Hello. The file is usually named Hello.java.
- public static void main(String[] args) — the entry point where the program starts running.
- System.out.println(...) — prints the text in quotes, then moves to a new line.
- Each statement ends with a semicolon ;
Output
Hello, Java! Day 1 done.
3 Practice
- Change the program so it prints your first name on one line and your college name on the next.
- Add a third line that prints: I am learning Java.
Try it in your own Java setup or write it in the Practice Notebook.
4 Quick Check
1. Where does a Java application start running?
2. What does System.out.println("Hi"); do?
3. Which symbol ends most Java statements?
Step 5
Answer and check the Quick Check above to unlock this.