Category: Java

Added: 19th of October 2021

Viewed: 111 times

Printing to console in Java using the System.out.println() command, learning Java

What does the code do?
The java code below prints Welcome to My Computer Tips in the console

To print to console in Java we use the System.out.println command.
The following java code prints Welcome to My Computer Tips

public class ConsoleMessage {

public static void main(String[] args) {

System.out.println("Welcome to My Computer Tips");
}

}


Create a new file then copy and paste the code above
Save the file as ConsoleMessage.java

Next open the terminal, and enter the following command to compile the file
javac ConsoleMessage.java


A new file named ConsoleMessage.class will be created

To execute the code enter the following command
java ConsoleMessage

Other Tips & Tutorials

Java

Install Bluej on Ubuntu, Java Development Environment for beginners

Posted: 19th of November 2021

Views: 127

Java

Simple for loop in Java. Print the numbers 1 to 10 in the console

Posted: 13th of November 2021

Views: 219

Java

Reading user input and outputting the results to console in Java using Scanner class

Posted: 27th of October 2021

Views: 152

Java

Printing to console in Java using the System.out.println() command, learning Java

Posted: 19th of October 2021

Views: 111

Java

How to compile your Java code using the terminal in Linux, Learning Java

Posted: 16th of October 2021

Views: 171