Remove the comma after the last number in a loop
java
Solution
Since everyone is having a field day, here's mine:
while (number > 0) {
System.out.print( number % 10 + ((number/=10)>0 ? "," : ""));
}
Problem
this is my code ``` System.out.println("Enter any integer number "); int number = scan.nextInt(); while (number > 0) { System.out.print( number % 10 + ",");number = number / 10;} ``` To clarify if the user enter 1234 the output should be 4,3,2,1, how can i edit the code to remove the comma after the last num? something like 4,3,2,1