Every time I try to execute this code it tells me that there is a lossy conversion from long to int. To my knowledge, there is not a single int in this code. The only thing I suspect is that one of the functions only returns an int. If so, how do I convert that into a long?
Also, does anyone see any errors in the last tow lines? I'm trying to convert an array into a list and I'm not sure that will work
And yes, I am aware that there are many other issues here, I'm just focused on this one specifically
import java.util.List;
class SumDigPower {
public static List<Long> sumDigPow(long a, long b) {
long solution = 0;
long solutionCounter = 0;
long[] solutionArray;
long[] digitArray;
for (long i = a; i < b; i++) {
String strLong = Long.toString(i);
String[] strArray = strLong.split("");
for (long j = 0; j < strArray.length; j++) {
digitArray[j] = Long.parseLong(strArray[j]);
} for (long k = 0; k < digitArray.length; k++) {
solution += Math.pow((k+1), digitArray[k]);
} if (solution == i) {
solutionArray[solutionCounter] = solution;
solution = 0;
solutionCounter += 1;
}
} List<Long> solutionList = Arrays.asList(solutionArray);
return solutionList;
}
}