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. Declaring int result within the method will change
View Tutorial          By: Soph at 2013-02-06 06:11:39

2. it's cool
but on other way it is indeed har

View Tutorial          By: johncarlo at 2009-02-05 04:44:13

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

4. Good example but hard to read. Every other word is
View Tutorial          By: Eugene at 2012-03-28 12:19:44

5. good
View Tutorial          By: Sudip Khatiwara at 2010-04-23 00:52:58

6. superb...thanks :-)
View Tutorial          By: sunny at 2010-11-10 07:20:25

7. Please i want to ask if this solution is really wo
View Tutorial          By: Enas Sabry at 2008-02-20 04:16:39

8. it is very good service.
View Tutorial          By: rajesh at 2009-11-14 02:48:18

9. Except for when you're programming low level hardw
View Tutorial          By: Jonathan H at 2012-05-10 08:46:48

10. it is really BEST answer of my question.
MR

View Tutorial          By: Ramesh genwa at 2010-09-09 07:15:37