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

How to output integers in java

下次还敢
下次还敢Original
2024-04-21 02:37:11485browse

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>

Parameters:

  • Integer: The integer to be output .

Example:

Output integer <code>123</code>:

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

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

<code>123</code>

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>

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

<code>123456</code>

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!

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