This is a program to read an integer:
public static void main(String argv[]) {
Scanner input = new Scanner(System.in);
int x = input.nextInt();
System.out.println(x);
}
But if I enter an input like this: 000114 it will be read like 114.How to read integer starts with zeroes?
input.next()orinput.nextLine()and then you can convert it to an int withInteger.parse()Stringis what you need.Stringto anint. I believe this is not a dupe of the question you have linked.