提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
带while循环的倒数
public class Main { public static void main(String[] args) {/**来 自 时代Java公众号 - N o w J a v a . c o m**/ int number = 1234; int reversedNumber = 0; int temp = 0; while(number > 0){ //use modulus operator to strip off the last digit temp = number%10; //create the reversed number reversedNumber = reversedNumber * 10 + temp; number = number/10;