error: incompatible types: ‘Something’ cannot convert to ‘Something’

a[i] = Double.toString(a[i]);

The left-hand side, a[i], is a variable of type double. The right-hand side, Double.toString(a[i]), is a value of type String. So you’re trying to assign a String to a variable of type double, hence the error: you can’t store a String in a variable of type double, because a String is not a double.

The second error is similar: The signature of the exchange method is exchange(String[] a, int i, int j). So it expects an array of String as first argument. You’re passing a. And a is declared as double[] a. So it’s an array of doubles, not an array of Strings.

Browse More Popular Posts

Leave a Comment