Сейчас буду вникать в правильное решение, но почему моё не годится? ведь если мы выкидываем символы из числа, оно в любом случае меньше чем исходное?
package com.javarush.task.jdk13.task12.task1203;
/*
Сознательный выбор
*/
public class Solution {
public static void main(String[] args) {
System.out.println(isByte(12)); // true
System.out.println(isShort(130999)); // false
System.out.println(isInt(1999939990L)); // true
System.out.println(isInt(19999999939990L)); // false
}
public static boolean isByte(long l) {
byte dif = (byte) l;
boolean res = (l <= dif);
return res;
}
public static boolean isShort(long l) {
short dif = (short) l;
boolean res = (l <= dif);
return res;
}
public static boolean isInt(long l) {
int dif = (int) l;
boolean res = (l <= dif);
return res;
}
}