私は太字のビットについて混乱しています。それは正確には何を意味し、解決策を見ずにどのようにこれを理解したのでしょうか? コードは機能しますが、太字のビットがわかりません。
public int sumOfDigits(int n)
{
int sum = 0;
n = Math.abs(n); //removes the minus sign from a negative integer
while (n > 0)
***{
sum += n % 10; //???????????????????????????????????????xplo
n /= 10;
}***
return sum;
}
public void inputAndProcess()
{
int n = 0;
Input in = new Input();
while (true)
{
System.out.print("Type an integer: ");
if (in.hasNextInt())
{
n = in.nextInt();
break;
}
in.nextLine();
System.out.println("You did not type an integer, try again.");
}
System.out.print("The sum of the digits of " + n);
System.out.println(" is: " + sumOfDigits(n));
}
public static void main(String[] args)
{
new Example1_1().inputAndProcess();
}
選択したビットを太字にすることはできませんが、それは*で覆われたコードの一部であり、これらの種類の古風なコードをより良くするためのヒントはありますか?