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. I need Structs full notes with examples
View Tutorial          By: Thomas at 2012-10-24 11:18:11

2. thanks for this tutorial
View Tutorial          By: d3ptzz at 2009-08-03 23:38:57

3. help me in my final project about arrays
View Tutorial          By: grace at 2013-03-13 09:54:11

4. introduction is very clear i get wat answer i want
View Tutorial          By: kalyan at 2013-07-02 09:23:40

5. good explanation .... Thanks
View Tutorial          By: nazeer at 2012-05-24 09:18:19

6. my question is how do this program connect to my
View Tutorial          By: ravisskit at 2012-10-08 12:00:18

7. How to download a pdf file from the server and sav
View Tutorial          By: harsha at 2013-08-12 07:52:22

8. i Want Struts Full Details with
Word forma

View Tutorial          By: Kannan.R at 2007-10-04 00:40:27

9. sir , i am new in j2me and i want to learn more s
View Tutorial          By: vipin Luhach at 2012-01-19 06:43:27

10. its not solve my problem.i.e
the concept is

View Tutorial          By: murli at 2010-10-02 23:23:11