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



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. Hi Steven. It looks like your example program does
View Tutorial          By: Ben Hallinan at 2008-04-25 08:36:42

2. Any Solution for below Error,

*** t

View Tutorial          By: Mazher at 2009-08-02 02:08:52

3. I faced an exception "java.net.connectExcepti
View Tutorial          By: Sandhya Rani Vellanki at 2010-11-15 00:39:24

4. Being a freshman in blogging, I really appreciate
View Tutorial          By: tyu at 2009-09-03 08:12:32

5. thanx allot its a very good sample , but im trying
View Tutorial          By: Waleed Qaffaf at 2011-06-09 09:37:15

6. Nice example for FileReader and FileWriter,

View Tutorial          By: Tim at 2009-10-21 17:31:00

7. sorry i think that's a constructor...just had one
View Tutorial          By: Gautam at 2013-10-14 15:55:14

8. package com.anand;

import java.sql.

View Tutorial          By: Anand at 2012-11-12 00:00:07

9. I did not understand it. please give one example e
View Tutorial          By: farhaan at 2008-03-20 12:06:11

10. very easy and simple program..
need minor

View Tutorial          By: Metal at 2014-05-07 10:31:04