Home >Java >javaTutorial >How to output integers in java
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
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!