Home >Java >Javagetting Started >How to output data in java

How to output data in java

王林
王林Original
2019-11-20 13:26:126569browse

How to output data in java

Output statement in java:

System.out.println(1111);//换行打印
System.out.print(1111);//不换行打印
System.out.write(2222);//字节输出
System.out.printf("%+8.3f\n", 3.14);//按格式输出

System.out.println(); is the most commonly used output statement, it will put the brackets The content in is converted into a string and output to the output window (console) with line breaks. When the output is a basic data type, it will be automatically converted into a string. If the output is an object, the object's toString(() will be automatically called. ); method, output the return value to the console.

System.out.print(); Very similar to the first one, the difference is that the previous output will have a newline, but this command will not have a newline after the output.

System.out.printf(); This method continues the output method of C language and outputs through formatted text and parameter list.

Recommended tutorial: java introductory tutorial

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

Statement:
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