Решение нашел, но не понимаю, почему мое решение не принимается, условием ведь соответствует и делает то, что должно.
Очень неприятно потратить время на решение, выполнить условия, а затем скопировать решение чужое, ибо твое не проходит по непонятной причине.
package com.javarush.task.task15.task1519;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; ; i++) {
Object a = reader.readLine();
if (a.equals("exit") == true) break;
else if (isDouble(a) == true) print(Double.parseDouble((String) a));
else if (isShort(a) == true) print((short) Integer.parseInt((String) a));
else if (isInteger(a) == true) print(Integer.parseInt((String) a));
else print((String) a);
}
}
private static boolean isDouble(Object o) {
boolean bool = false;
StringBuffer l = new StringBuffer((String) o);
for (int i = 0; i < l.length(); i++) {
char a = l.charAt(i);
String b = Character.toString(a);
if (b.equals(".") == true) bool = true;
}
return bool;
}
private static boolean isShort(Object o) {
boolean bool = false;
try {
int a = Integer.parseInt((String) o);
if ((a > 0) & (a < 128)) bool = true;
} catch (NumberFormatException e) {
}
return bool;
}
private static boolean isInteger(Object o) {
boolean bool = false;
try {
int a = Integer.parseInt((String) o);
bool = true;
} catch (NumberFormatException e) {
}
return bool;
}
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);
}
}