aspose file tools
The moose likes Beginning Java and the fly likes String object declaration problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "String object declaration problem" Watch "String object declaration problem" New topic
Author

String object declaration problem

MohamedSalim malik
Greenhorn

Joined: Feb 04, 2011
Posts: 19

In my SCJP class they taught us like Strings are considered as Objects in java.. If so the above s1,s2 should be two references which points to TWO OBJECTS . Am i correct.?
But when i compile and run this i got a result showing true. I am confused


then i made another program..




When i run this, it showed the boolean value as 'false'. It indicates that this is two different objects.(is that correct?) My question is that, which is considered as
a OBJECT in java From above two declarations.?? can someone explain me?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14669
    
  11

We have a Journal article about Strings and the String pool. Check it here.


[My Blog]
All roads lead to JavaRanch
MohamedSalim malik
Greenhorn

Joined: Feb 04, 2011
Posts: 19
Awesome artical.. now i got it.. thanks for your help.. :
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String object declaration problem
 
Similar Threads
Two ways to construct a String/pool of strings problem
== with Strings is giving a different result
== & equals()
String object
String and String Object Problem