Home > Java > javaTutorial > body text

How to type java hello word

little bottle
Release: 2019-05-21 16:10:50
Original
6171 people have browsed it

Nowadays, many friends come to learn Java together. Some friends ask how to use Java to output hello world? I will tell you in this article below. Friends who need to know more should read it. I hope it will be helpful to you.

How to type java hello word

Open the java runtime environment (the software used to write java programs), then enter the following statement, click compile and run, and then "Hello World," will be output.

public class Test{    //1
public static void main(String args[]){   //2
System.out.println("HelloWorld,");   //3
}
}
Copy after login

This method is to directly call java's printfln function to complete the output operation.

1 is to create a "Test" class.

2 is the declaration statement of the main method.

3 is the output statement, output "HelloWold".

There are three commonly used output statements in java:

1.System.out.println(); is the most commonly used output statement , it will convert the content in brackets into a string and output it to the output window (console), and wrap the line. When the output is a basic data type, it will be automatically converted into a string. If the output is an object, it will be automatically converted into a string. Call the toString(); method of the object and output the return value to the console;

2.System.out.print(); is very similar to the first one, the difference is the previous one Line breaks will occur after output, but this command will not break lines after output;

3.System.out.printf(); This method continues the output method of C language, by formatting text and parameter list output.

The above is the detailed content of How to type java hello word. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template