Comment on Tutorial - equals( ) Versus == in Java By Mashoud



Comment Added by : Gunjan

Comment Added at : 2010-09-08 19:24:24

Comment on Tutorial : equals( ) Versus == in Java By Mashoud
Hello Friends ,

s1 == s2 will always give false . Because s1 == s2 gives refers to the different memory location .

Note that , in java every object refers to the different memory locations. So , == will always give you false.
If we declare s1=s2 then it will give true . While s1.equals(s2) compares the character within the String object . So it will give true.


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. Look this framework (https://code.google.com/p/lin
View Tutorial          By: Mariane at 2013-07-04 14:27:52

2. i am getting following error

Error

View Tutorial          By: Pavan at 2009-11-26 21:31:22

3. yes 29 you are correct! 27's example is prone to a
View Tutorial          By: sameendra at 2011-07-24 11:55:54

4. hi,im working with a project,in which i have to se
View Tutorial          By: gomathi at 2008-12-08 09:04:35

5. Never use gets for taking inputs from users. Your
View Tutorial          By: Aneesh Dogra at 2012-07-20 04:08:32

6. Good start for me. At least I now know what i am s
View Tutorial          By: eoaddai at 2011-12-23 20:53:35

7. if i wanna push the data from my keyboard input, h
View Tutorial          By: andys at 2008-11-09 03:09:32

8. Write a times table programme. The programme shoul
View Tutorial          By: Hannah Jambalos at 2014-09-03 12:07:34

9. Hello,
how to use tjis tut for load image f

View Tutorial          By: zero at 2013-10-30 11:45:33

10. Good To understand.
View Tutorial          By: Radhika at 2010-05-11 01:24:55