MyInteger { public static int parseInt(char[] c) { int rv = 0; for (int i = 0; i < c.length; i++) { if (c[i] > '9' || c[i] < '0') { return -1; } } for (int i = 0; i < c.length; i++) { rv *= 10; rv = rv + (c[i] - '0'); } return rv; } MyInteger(int value); int get(); boolean isEven(); boolean isOdd(); boolean isPrime(); static boolean isEven(int v); static boolean isOdd(int v); static boolean isPrime(int v); static boolean isEven(MyInteger v); static boolean isOdd(MyInteger v); static boolean isPrime(MyInteger v); @Override boolean equals(Object o); boolean equals(int v); boolean equals(MyInteger v); static int parseInt(char[] c); static int parseInt(String c); @Override String toString();  }
@Test @DisplayName("测试parseInt静态成员函数的各个版本") void testParseInt(){ assertEquals(23464, MyInteger.parseInt("23464")); assertEquals(2732923, MyInteger.parseInt(new String("2732923"))); c = new char[8]; for(int i=0; i<c.length; i++){ c[i] = (char)(i + '1'); } assertEquals(12345678, MyInteger.parseInt(c)); }