aspose file tools*
The moose likes Beginning Java and the fly likes string doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "string doubt" Watch "string doubt" New topic
Author

string doubt

Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

String a ="Arnold";

now a is an reference variable or object,if object hows that possible because new keyword is used whenever we create an object


http://www.lifesbizzare.blogspot.com || OCJP:81%
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14269
    
  21

Anything between "quotes" in your source code is a String object.

It would be really annoying if Java did not have native support for strings and you'd have to do difficult things just to have a string in your source code. It would become really tedious if you'd have to write something like this every time:


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Even using 'new' with Strings seems like a lot of work. The JVM has really spoiled us .

John.
Embla Tingeling
Ranch Hand

Joined: Oct 22, 2009
Posts: 237
Vishal Hegde wrote:String a ="Arnold";

now a is an reference variable or object,if object hows that possible because new keyword is used whenever we create an object


Although String is a class, it has been given special language support to behave almost like a primitive. The String literal "Arnold" will be represented by an internal String object which reference is used every time "Arnold" appears.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
. . . and using the new keyword for Strings will cause unintended results, eg two identical Strings. This is quite unnecessary for 99.9% of applications.
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

thank you


Campbell Ritchie
Mr. nossnahoj
John De Michele
Jesper Young


love you all
guys i am able to unable to learn java in a simpler way

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
You're welcome

But I don't think it's Mr Nassnahoj
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
It's probably nassnahoJ .rM

John.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
No, it's not .rM either. At least I don't think it is.
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1688
    
  12

It seems the assumption around here is that everyone is male. Makes me crazy.


When you do things right, people won't be sure you've done anything at all.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Janeice DelVecchio wrote:It seems the assumption around here is that everyone is male. Makes me crazy.

I make a point of correcting that false assumption when it comes up for me. I've noticed other moderators do the same when someone calls me "he." As does my co-blogger.

Don't let it bother you . It's much more interesting to think of it as teaching people about female techies....


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
You are right to make a point of correcting it, Jeanne; I also make sure to tell people not to call you or Joanne Neal "Sir".
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1688
    
  12

Maybe I'll just break down and donate $$ to get a custom title...

I think "Java Princess" or "Drama Queen" would do it
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39415
    
  28
Janeice DelVecchio wrote:Maybe I'll just break down and donate $$ to get a custom title...

I think "Java Princess" or "Drama Queen" would do it
We have enough drama queens on "beginning Java" already. Please don't turn into one But Paul will be all over you if you threaten to donate $$
Vishal Hegde
Ranch Hand

Joined: Aug 01, 2009
Posts: 1055

ohk is it Mrs Johanssan then

why to have your name upside down its not a password
Deepak Nayak
Greenhorn

Joined: Nov 05, 2009
Posts: 3
Campbell Ritchie wrote: . . . and using the new keyword for Strings will cause unintended results, eg two identical Strings. This is quite unnecessary for 99.9% of applications.


yes correct. Becasue if you make string object like this String s1= "John", it creates string object in String pool and when you create String s2 ="John", JVM doesn't create new object, instead it gives the reference of the same object to s2. it means both s1 and s2 will point to the same string object in String pool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: string doubt