• Post Reply Bookmark Topic Watch Topic
  • New Topic

String literal in println  RSS feed

 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
If i write a string literal inside println,then does the compiler creates that string literal in the String constant pool.I mean do we have again a new object?
Please reply.
Thanks...
 
Gaurav Raje
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should answer your question
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the suggestion,but i would appreciate if you could be more direct.
Do we get a new object or not?
Thanks...
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have been given a good and useful suggestion; please follow that suggestion.
 
Paul Clapham
Sheriff
Posts: 22828
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a direct answer: as far as the compiler is concerned, the println() method of PrintStream is the same as any of the other several thousand methods in the standard Java API.
 
Gaurav Raje
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sudhanshu Mishra wrote:Thanks for the suggestion,but i would appreciate if you could be more direct.
Do we get a new object or not?
Thanks...

While the direct answer is quite simple to give, here at javaranch, every1 believes in pointing to the resource than reading it out as much as you can. It serves two purposes
1) It saves the time required for typing an answer for every question which comes up
2) It makes you read a lot of other stuff and help in making you a better programmer.

I really find it useful at times, though sometimes even I feel it might be easier to get a direct answer. You might find it rudde initially, but looking back I really find it a better approach than getting answers directly. I stilll continue to ask obvious questions and expect obvious answers, but I am slowly getting the hang of it.

Dont mean to be rude, but it will help everyone.
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with you, Gaurav Raje.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!