1

I have only seen questions where Integer objects were involved in the discussion:

Java: Integer equals vs. ==

How do I compare two Integers?

and was wondering what the procedure should be for the primitive int.

int a = 250;
int b = 250;

System.out.println(a == b); // doesn't work for larger ints 127<
System.out.println(a.equals(b)); // doesn't work for primitive ints

What should one do in this case? Should one instead use the Object wrapper for int?

Community
  • 1
  • 1
ylun.ca
  • 2,504
  • 7
  • 26
  • 47

0 Answers0