Пока не могу понять, что не так
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Разные методы для разных типов
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
boolean b = true;
String key;
String strToDouble = "\\d+.\\d+";
String strToIntPlus = "\\d+";
String strToInt = "\\d";
while (!(key = reader.readLine()).equals("exit")) {
try {
if (key.matches(strToDouble) || key.matches(strToInt) || key.matches(strToIntPlus)){
if (key.matches(strToInt) || key.matches(strToIntPlus)){
int keyInt = Integer.parseInt(key);
if (keyInt > 0 && keyInt <128){
short keyShort = (short) keyInt;
print(keyShort);
}else {
print(keyInt);
}
}else {
Double keyDouble = Double.parseDouble(key);
print(keyDouble);
}
}else{
print(key);
}
} catch (NumberFormatException e) {
print(key);
}
}
}
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);
}
}