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. import java.io.*;
class CharaaDemofromnet
View Tutorial          By: bond at 2014-08-16 17:02:10

2. hi!
how can i add variable form object to a

View Tutorial          By: rushi at 2015-07-16 08:18:58

3. how to display images in j2me?? thank you :)
View Tutorial          By: bill at 2011-06-23 23:59:41

4. good
View Tutorial          By: Devil vampire at 2009-03-23 12:20:03

5. I an going to try this code.
View Tutorial          By: Bhagawati Prasad at 2010-02-06 02:45:10

6. Its informative and helpful. Thanx
View Tutorial          By: Usama at 2012-07-14 22:16:45

7. hi i unable to retrive am getting below excepti
View Tutorial          By: vignesh at 2015-03-25 17:14:58

8. I used the script above, and it seems to work exce
View Tutorial          By: Michael at 2012-05-15 20:50:49

9. sir how can i access url in one click
View Tutorial          By: mohit at 2010-05-28 23:10:23

10. sir,i m doing ME/CSE.i want to know more informati
View Tutorial          By: m.rajalakshmi at 2011-07-27 05:20:44