Simple Java Print Statement

Beginner

Introduction

In this challenge, you'll practice using the System.out.println statement in Java. This is a fundamental skill in Java programming that allows you to output text to the console. You'll modify a simple program to print a greeting message, then compile and run it.


Skills Graph

Create a Simple Greeting Program

Now that you've learned about the basic structure of a Java program and how to use System.out.println, let's put that knowledge into practice.

Tasks

  • Modify the existing SimpleGreeting.java file to print a greeting message to the console.
  • Compile the Java program using the appropriate command.
  • Run the compiled program using the appropriate command.

Requirements

  • Open the SimpleGreeting.java file located in the ~/project directory.
  • Use the System.out.println statement to print the greeting message "Hello, Java Programmer!".
  • Compile your program using the Java compiler in the terminal.
  • Run your program using the Java runtime in the terminal.
  • Ensure all work is done in the ~/project directory.

Example

Expected output after running the program:

Hello, Java Programmer!
Java program output example

Summary

In this challenge, we focused on using the System.out.println statement in Java, building upon the basic concepts introduced in the lab. We modified a simple program to print a greeting message to the console, and then compiled and ran it. This challenge demonstrates the practical application of the print statement, which is a fundamental part of Java programming, and reinforces the compilation and execution process for Java programs.