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. Apache was failing to deliver php pages that were
View Tutorial          By: Ted at 2010-11-13 08:13:29

2. Thanks...

Rohit
xpode.com

View Tutorial          By: Rohit at 2012-04-30 04:18:12

3. guys you both are correct
but,java is impli

View Tutorial          By: vijay at 2011-09-08 12:12:48

4. org.apache.jasper.JasperException: An exception oc
View Tutorial          By: manikanta at 2015-02-02 05:39:09

5. Very good explaination of transient and volatile.
View Tutorial          By: Himanshu Upadhyay at 2010-11-15 04:48:43

6. To "need help":

String s

View Tutorial          By: Mike at 2010-10-14 20:09:31

7. is anyone going to post the complete version of th
View Tutorial          By: anon at 2009-04-21 12:26:51

8. I have modified this example a bit and I'm using a
View Tutorial          By: Lee Murray at 2010-11-02 03:41:56

9. please explain thread t=new thread(this,name). Wha
View Tutorial          By: Bhavin at 2012-09-28 12:26:55

10. explanation is good but i have one doubt what is t
View Tutorial          By: sulthan at 2012-10-09 06:13:14