Author
How many Object is created?
Santanu Guha
Greenhorn
Joined: Jul 28, 2008
Posts: 9
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
posted Feb 17, 2011 06:07:13
1
One string one StringBuffer .
next.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
Welcome to the Ranch (after 2½ years ). There's no such thing as "urgent" here .
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
And one char[] inside the StringBuffer .
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
. . . 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: 2770
Santanu Guha wrote: It's UGENT !!!
Fixed.
subject: How many Object is created?