I'm trying to reverse a string of numbers and input comma without Number format class.
When a number like 1000 is inputted the output will be
0,0,0,1
Instead of
000,1
What I have tried:
String num=JOptionPane.showInputDialog("enter number");
Int length=num.length()-1;
String res="";
Char ch;
If(length<=6){
for(int k=length; k>=0; k--){
ch=num.chartAt(k);
res+=ch;
if(ch==num.chartAt(2)){
res+=",";
}
}
}
System.out.println(res);