Валидатор докопался до Short, как победить не понимаю.
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 buffer = new BufferedReader(new InputStreamReader(System.in));
int varStart = 0;
int var = 0;
while (true) {
String sa = buffer.readLine();
if (sa.equals("exit")) {
break;
}
if (inNumeric(sa) == true) {
int index1 = sa.indexOf(".");
if (index1 != -1) {
Double d = Double.parseDouble(sa);
print(d);
continue;
}
if ((Integer.parseInt(sa) <= 0) || (Integer.parseInt(sa) >= 128)) print(Integer.parseInt(sa));
else {
if ((Short.parseShort(sa) > 0) && (Short.parseShort(sa) < 128)) print(Short.parseShort(sa));
}
/*Integer num = Integer.parseInt(sa);
if (num > 0 && num < 128) {
short s = Short.parseShort(sa);
print(s);
}
if (num <= 0 || num >= 128) {
print(num);
}*/
}
else {
print(sa);
}
}
}
public static boolean inNumeric (String str) {
return str.matches("-?\\d+(\\.\\d+)?");
}
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);
}
}