I was trying to compare between decimals in floats using if statements, but I don\'t know how to do it. I searched a lot but didn\'t get the answer.
For example:
You can take a Double
and call toString
on it and then iterate over charArray like this
public class TestIndexOf {
public static void main(String[] args) {
Double d = 5.26;
String source = d.toString();
char[] chars = source.toCharArray();
char max = source.charAt(source.length() - 1);
boolean isMax = true;
for (char aChar : chars) {
if (max < aChar) {
max = aChar;
isMax = false;
}
}
System.out.println(max + " is max?" + isMax);
}
}