Home > Java > javaTutorial > How to output integers in java

How to output integers in java

下次还敢
Release: 2024-04-21 02:37:11
Original
502 people have browsed it

To output integers in Java, you can use System.out.println(integer). Other methods include System.out.print(integer), which does not wrap output.

How to output integers in java

How to output integers in Java

In Java, you can use System.out to output integers. println() method.

Syntax:

<code class="java">System.out.println(整数);</code>
Copy after login

Parameters:

  • Integer: The integer to be output .

Example:

Output integer <code>123</code>:

<code class="java">System.out.println(123);</code>
Copy after login

The output will be displayed on the console as follows Display:

<code>123</code>
Copy after login

Other ways:

In addition to the System.out.println() method, you can also use System. out.print() method outputs an integer. The difference from System.out.println() is that System.out.print() does not output on a new line, but appends to the current line.

Example:

Output integers <code>123</code> and 456:

<code class="java">System.out.print(123);
System.out.print(456);</code>
Copy after login

The output will be displayed in the control On stage, as shown below:

<code>123456</code>
Copy after login

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

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