how to integer in java code example
Example 1: string to int java
String number = "10";
int result = Integer.parseInt(number);
System.out.println(result);
Copy
Example 2: formatting an integer in java
Specifying a width:
String.format("|%20d|", 93); // prints: | 93|
Left-justifying within the specified width:
String.format("|%-20d|", 93); // prints: |93 |
Pad with zeros:
String.format("|%020d|", 93); // prints: |00000000000000000093|