String s = 000000001;
String e = 009999999;
Convert String 000000001 to Integer 000000001.
I tried doing this with Integer.parseInt
int n = Integer.parseInt(s);
I am getting n = 1, but I want n should have 000000001
for (int ind = Integer.valueOf(s); ind < Integer.valueOf(e); ind++) {
String pp = "ggg" + ind; // I want pp should be like this- ggg000000001 and it keep on increasing like ggg000000002, then ggg000000003 and etc etc.
}
The integer
000000001is1. I can only assume you want to display1as000000001. This is how you do it:Here’s a little test:
Output:
FYI
System.out.format()is a convenience facade forSystem.out.println(String.format()), so if you need the String in your code (and don’t want to output it) use:Updated due to question update: