import java.time.LocalDateTime; import java.util.List; public class LongRangeKnownMethods { void testIndexOf(String s) { int idx = s.indexOf("xyz"); if(idx >= 0) { System.out.println("Found"); } else if(idx == -1) { System.out.println("Not found"); } } void testLocalDateTime(LocalDateTime ldt) { if(ldt.getHour() == 24) System.out.println(1); if(ldt.getMinute() >= 0) System.out.println(2); if(ldt.getSecond() >= 60) System.out.println(3); } private static int twiceIndexOf(String text, int start, int end) { int paragraphStart = text.lastIndexOf("\n\n", start); int paragraphEnd = text.indexOf("\n\n", end); if (paragraphStart >= paragraphEnd) { return text.length(); } return (paragraphStart >= 0 ? paragraphStart + 2 : 0) + (paragraphEnd < 0 ? text.length() : paragraphEnd); } void test(String s) { if (s.isEmpty() && s.length() > 2) { System.out.println("Never"); } } void test2(String s) { if (s.isEmpty() && s.length() == 0) { System.out.println("Ok"); } } void test3(String s) { if (s.startsWith("xyz") && s.length() < 3) { System.out.println("Impossible"); } } void testEmpty(String s) { if (s.isEmpty() && s.startsWith("xyz")) { System.out.println("Impossible"); } } void testOk(String s) { if (s.length() <= 3 && s.endsWith("xyz")) { System.out.println("Possible"); } } void testInterfere(String s, String s2) { if (!s.isEmpty() && s2.startsWith(s)) { if(s2.isEmpty()) { System.out.println(); } } } void test4() { String s = "abcd"; if (s.startsWith("efg")) { System.out.println("Impossible"); } } void testEquals(boolean b, boolean c) { String s1 = b ? "x" : "y"; String s2 = c ? "x" : "b"; if(s1.equals(s2) && b) { System.out.println("B is always true"); } } void testEqualsIgnoreCase(String s) { if(s.equalsIgnoreCase("xyz") && s.isEmpty()) { System.out.println("Never"); } } void testIndexOfUpperBound(String s) { int idx = "abcdefgh".indexOf(s); if(idx > 8) { System.out.println("Impossible"); } } void testMax(int x) { x = Math.max(x, 0); if (x > -1) { System.out.println("Always"); } if (x > 0) { System.out.println("Not always"); } } void testMin(long x, long y) { if (x < 10 && y > 10) { y = Long.min(x, y); if (y > 20) { System.out.println("Impossible"); } } if (y > 20) { System.out.println("Possible"); } } void testMinMax(List rows) { int start = Integer.MAX_VALUE; int end = -1; for (int i = 0; i < rows.size(); i++) { String row = rows.get(i); if (!row.isEmpty()) { start = Math.min(start, i); end = Math.max(end, i); } } if(end >= 0 && start < Integer.MAX_VALUE) { System.out.println("Ok"); } } void testAbs(long x, int y) { x = Math.abs(x); y = Math.abs(y); if (x == Long.MIN_VALUE) { System.out.println("possible"); } if (x == Long.MIN_VALUE + 1) { System.out.println("impossible"); } if (x == Integer.MIN_VALUE) { System.out.println("impossible"); } if (y == Integer.MIN_VALUE) { System.out.println("possible"); } else if(y < 0) { System.out.println("impossible"); } } }