Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Virudada

Comment Added at : 2012-05-05 06:27:22

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
import java.util.*;

public class demo {
public static void main(String[] args) {
int q=1;
int r=2-1;
Integer t=new Integer(1);
System.out.println(q==t);
System.out.println(t.equals(r));
System.out.println(q==r);
}
}

Output -

true
true
true

Please give me the explanation.
Many thanks in advance!


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Your solution won't work if you have 2 different f
View Tutorial          By: mkieu at 2012-06-19 00:04:29

2. Thanks. Helped me save few hours
View Tutorial          By: Balan at 2008-04-07 18:25:08

3. Thanks a lot for this very fruitful and amazingly
View Tutorial          By: Gaurav Saxna at 2011-06-15 06:20:18

4. its good
View Tutorial          By: sumanth at 2010-04-10 20:10:00

5. How do you remove an element from the map?
View Tutorial          By: Shreejit at 2012-01-29 16:53:27

6. Pl send some sample program for speech to text wit
View Tutorial          By: gokul at 2012-09-27 10:28:19

7. Actually, the given accuracy just barely exceeds w
View Tutorial          By: William Fraser at 2015-06-07 16:37:52

8. we generally use this keyword for referring to the
View Tutorial          By: madhu at 2012-02-07 14:11:57

9. can u p-lease tell me the clear idea of how to sto
View Tutorial          By: osman at 2010-08-19 04:33:37

10. I have a website and i want to make a option to se
View Tutorial          By: rasel at 2011-11-26 15:50:49