This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How many Object is created?

 
Santanu Guha
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

Can you tell me how many Objects are created created in Heap and in "String Literal Pool" when i execute the below code in java : --
Is tere any Pool memory affected by "Santanu"
?
StringBuffer sb = new StringBuffer("Santanu");

Thanks in Advance
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One string one StringBuffer.
next.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch (after 2½ years ). There's no such thing as "urgent" here.
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David O'Meara wrote:One string one StringBuffer.
next.

And one char[] inside the StringBuffer.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and a char[] inside the String?

4 and counting
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can analyze output of de assembler and can conclude on number of objects created.

Run javap -c <class name> on your class and see the output.
 
Mike Simmons
Ranch Hand
Posts: 3038
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santanu Guha wrote:It's UGENT !!!

Fixed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic