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. Notice that on an UNIX environment (including Linu
View Tutorial          By: Alejandro segovia at 2011-02-22 11:08:23

2. Is so easy work with FacesContext. For me, the get
View Tutorial          By: Fred at 2009-03-11 08:42:59

3. thanks it is nice
View Tutorial          By: Ajay at 2011-07-22 03:44:05

4. This is pretty straightforward and got me to under
View Tutorial          By: Renoir Boulanger at 2009-09-01 09:49:24

5. i want to fetch some rows from database using ESQL
View Tutorial          By: anonymous at 2013-03-14 14:17:19

6. The tutorial, it's very easy to be understood

View Tutorial          By: newcomer at 2012-04-25 03:49:35

7. hi its working nice,can u plz help me how to fetch
View Tutorial          By: Manju gowda at 2014-02-21 07:23:44

8. It was actually useful!!! Thanks for explaining in
View Tutorial          By: steph at 2010-01-28 21:59:06

9. Excellent
View Tutorial          By: Jaleel at 2009-10-16 23:22:52

10. i got an error msg at runtime of jdbc program with
View Tutorial          By: madhu sudan at 2012-06-17 02:52:53