wood burning stoves 2.0*
The moose likes Java in General and the fly likes How many Object is created? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How many Object is created?" Watch "How many Object is created?" New topic
Author

How many Object is created?

Santanu Guha
Greenhorn

Joined: Jul 28, 2008
Posts: 14
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

Joined: Mar 06, 2001
Posts: 13459

One string one StringBuffer.
next.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
Welcome to the Ranch (after 2½ years ). There's no such thing as "urgent" here.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

David O'Meara wrote:One string one StringBuffer.
next.

And one char[] inside the StringBuffer.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38087
    
  22
. . . and a char[] inside the String?

4 and counting
Siddhesh Deodhar
Ranch Hand

Joined: Mar 05, 2009
Posts: 117
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.


Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3003
    
    9
Santanu Guha wrote:It's UGENT !!!

Fixed.
 
jQuery in Action, 2nd edition
 
subject: How many Object is created?
 
Similar Threads
How many Objects are created ?
Does new operator create new StringBuffer object???
do StringBuffer have String pool
String concatenation
Question on Garbage Collection