I have a code which is supposed to get the current OS version, so lets say the computer I use, is running Windows 10 then it would output 10. The code in theory should work, but there is a slight problem. The code itself does not give any errors, but whenever I run it I get the console error.
Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.lang.NumberFormatException: For input string: "10.0"
I am not completely sure where my code is wrong, but there is definitely something which is not connecting.
Here is the code
private static String OSV = System.getProperty("os.version").toLowerCase();
static int OSVnum = Integer.parseInt(OSV);
static void windRoc() throws IOException {
if (OSVnum == 10.0) {
System.out.println("It is working!");
} else if (OSVnum == 7) {
stop1();
} else {
stop2();
}
}