Выскакивает ошибка на String, хотя если указать else print(score) та-же самая песня. Но почему этот не подходит?
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String score = null;
while (true) {
score = reader.readLine();
if (score.equals("exit")) {
break;
}
if (score.contains(".")) {
print(Double.parseDouble(score));
} else if (Integer.parseInt(score) > 0 && Integer.parseInt(score) < 128) {
print(Short.parseShort(score));
} else if (Integer.parseInt(score) >= 128 || Integer.parseInt(score) <= 0) {
print(Integer.parseInt(score));
} else if(!(score.contains(".")) || !(Integer.parseInt(score) > 0 && Integer.parseInt(score) < 128) || !(Integer.parseInt(score) >= 128 || Integer.parseInt(score) <= 0)) {
print(score);}
}
}
public static void print(Double value) {
System.out.println("Это тип Double, значение " + value);
}
public static void print(String value) {
System.out.println("Это тип String, значение " + value);
}
public static void print(short value) {
System.out.println("Это тип short, значение " + value);
}
public static void print(Integer value) {
System.out.println("Это тип Integer, значение " + value);
}
}