I think I did something wrong with my algorithm that I was trying to split my number 150000 into thousands with for loop. I want the output to be like 150,000. I was just having trouble coming up with a nice way doing it.
Here are my codes:
public class testing {
public static void main(String[] args) {
// TODO Auto-generated method stub
String l= "150000";
for(int i=l.length();i<0;i--){
if ((i/4)==0){
l=","+l.substring(i, l.length()-1);
}
}
System.out.println(l);
}
}