• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How many objects will create

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have faced one query. how many objects will create for below code.

String s1="hi";
String s2=new String("hi");
String s3="hi";


How can I know how many objects will create. can any one please suggest me.

regards,
ramesh
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you don't know much about strings, check this Journal article.
 
ramesh kv
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks....
 
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please tell us how many objects you think are created.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Deleted]
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Raphael Okochu, please read this:

We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.

from the header for this forum.

It does nobody any good to have their questions answered before they have a chance to think themselves. Ramesh KV ought to have thought about it for himself; by providing an explanation too early you may have deprived him of the opportunity to learn.
Don't be annoyed with me, but I have pulled rank and deleted your answer. Please let people think for themselves in future.
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
four hundred and fifty-two



so,there are four hundred and fifty-two object created.
hope this helps!

[edit]Delete code and alter number of objects. CR[/edit]
 
Raphael Okochu
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Raphael Okochu, please read this:

We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.

from the header for this forum.

It does nobody any good to have their questions answered before they have a chance to think themselves. Ramesh KV ought to have thought about it for himself; by providing an explanation too early you may have deprived him of the opportunity to learn.
Don't be annoyed with me, but I have pulled rank and deleted your answer. Please let people think for themselves in future.

rr

Hi Campbell, you're right.. No problem
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Baichuan Huang wrote:so,there are four hundred and fifty-two object created.
hope this helps!

No, it doesn't help at all. Didn't you read my post immediately before yours?
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Raphael Okochu wrote: . . . Hi Campbell, you're right.. No problem

 
Baichuan Huang
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Baichuan Huang wrote:so,there are four hundred and fifty-two object created.
hope this helps!

No, it doesn't help at all. Didn't you read my post immediately before yours?



im so sorry,My answer was deleted
there are four hundred and fifty-two object created.
its not my answer.please trust me .
sorry again!
 
Campbell Ritchie
Marshal
Posts: 79180
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Baichuan Huang wrote: . . . its not my answer.please trust me . . .

If he really believes four hundred and fifty-two, he has got problems.

You should be apologising for giving your answer immediately after I explained why I had deleted a previous similar post.
 
Baichuan Huang
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Baichuan Huang wrote: . . . its not my answer.please trust me . . .

If he really believes four hundred and fifty-two, he has got problems.

You should be apologising for giving your answer immediately after I explained why I had deleted a previous similar post.


Interesting, now ,I know it .thanks!
I have some harvest from your information .
thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic