我正在解决这个问题,以找到具有相同数字集的下一个最大数字。
为此,我获取用户输入的整数值,并希望将其转换为 char 数组或 int 数组,以便可以访问各个数字。
但是当我采取
int value=09 作为输入并转换为 char 数组,它只给出 9,因为它认为它是八进制值。我怎样才能克服这个问题?
最佳答案
it is not possible in java to take the int values with leading zeros. so for the value with leading zeros take it in string format.
but we can insert zeros
block 引用>int n=7;
String str=String.format("%04d", n); //4 denotes the size of the string
System.out.println(str); // o/p->0007
关于java - 如何将 int 值 09 转换为 char 数组 {'0' ,'9' }?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60892514/