java - how to use primitive types properly -


int x = 10; int y = 10;  integer x1 = new integer(10); integer y1 = new integer(10);  system.out.println(x == y); system.out.println(x1 == y1); 

the first sop print true whereas second 1 print false. actual problem ?

the second approach not checking values rather objects.

if want compare values of 2 integer objects have use appropriate methods compareto(integer)

like mentioned in comments if want check equality can use equals


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -