Hızlı yanıt: kod örneği
I could get some sample code to compile successfully in Java 1.5 and 1.6, but not in 1.4.This is the error in 1.4:The most reasonable explanation is that because Java introduced autoboxing and autounboxing in 1.5, you must be using a Java compiler from before 1.5, say, 1.4.Solutions:
Integer % Integer
public static void main(String[] args){ Integer x = 10; Integer y = 3; System.out.println(x % y);}
ModTest.java:7: operator % cannot be applied to java.lang.Integer,java.lang.Integer System.out.println(x % y); ^
- Upgrade to Java 1.5/1.6/1.7.
- If you must use 1.4, use to extract the
Integer.intValue()
values, on which you can use theint
operator.%