Skip to main content
added 111 characters in body
Source Link
Raghunandan
  • 133.6k
  • 26
  • 232
  • 261

Use

 if ("lamp".equals(DeviceType)) { //do something } 

The operator, ==, tests to see if two object reference variables refer to the exact same instance of an object.

The method, .equals(), tests to see if the two objects being compared to each other are equivalent -- but they need not be the exact same instance of the same object.

http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html

Check the equals method in the link above

Use

 if ("lamp".equals(DeviceType)) { //do something } 

The operator, ==, tests to see if two object reference variables refer to the exact same instance of an object.

The method, .equals(), tests to see if the two objects being compared to each other are equivalent -- but they need not be the exact same instance of the same object.

Use

 if ("lamp".equals(DeviceType)) { //do something } 

The operator, ==, tests to see if two object reference variables refer to the exact same instance of an object.

The method, .equals(), tests to see if the two objects being compared to each other are equivalent -- but they need not be the exact same instance of the same object.

http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html

Check the equals method in the link above

Source Link
Raghunandan
  • 133.6k
  • 26
  • 232
  • 261

Use

 if ("lamp".equals(DeviceType)) { //do something } 

The operator, ==, tests to see if two object reference variables refer to the exact same instance of an object.

The method, .equals(), tests to see if the two objects being compared to each other are equivalent -- but they need not be the exact same instance of the same object.