how to print a number in java code example
Example 1: how to output given number java
import java.util.Scanner;
public class HelloWorld {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
int number = reader.nextInt();
System.out.println("You entered: " + number);
}
}
Example 2: print an integer in java
public class HelloWorld {
public static void main(String[] args) {
int number = 45;
System.out.println("You entered: " + number);
}
}