The compiler says that the 'sum' on the right side of the equal sign on line 17 might not have been initialized. How do I correct this?
package com.codegym.task.task01.task0132;
/*
Sum of the digits of a three-digit number
*/
public class Solution {
public static void main(String[] args) {
System.out.println(sumDigitsInNumber(546));
}
public static int sumDigitsInNumber(int number) {
//write your code here
int sum;
while(number > 0) {
sum = sum + number % 10;
number = number /10;
}
return sum;
}
}