practice of the Java method;


I am practicing to write the Java method in (Auto-Graded Course (AP CS A) ) but anytime I get the error. Thank you for replies.

Instructions from your teacher:

Failed tests: ./ error: reference to assertEquals is ambiguous

The requirement here is a bit unclear.

Returns: an integer

In Java, 4 types can be used to stored integers - int, Integer, long, Long. Which type does the question actually want you to use?

Judging from the fact that the return value is 2, without a l or L suffix, we can guess that long and Long aren't what it is looking for.

Now, do we use int or Integer?

Obviously, since you tried Integer and it failed the test, it's gotta be int.

Also, this is kind of a "cultural" (can't think of a better word) thing, where if you ask a Java programmer to create an integer variable, they will almost definitely use int instead of Integer.

The use of Integer is far less frequent than that of int. For me, I only use it in generic type parameters, where int cannot be used.