
- Forum
- Programming Talk
- Java
- Object Count..
Object Count..
This is a discussion on Object Count.. within the Java forums, part of the Programming Talk category; Can anybody help me to count how many objects are created during runtime in a java class as... As in... ...
-
Object Count..
Can anybody help me to count how many objects are created during runtime in a java class as...
As in...
String s1="abc";
s1.concat(s1);
s1.replace('a','z');
How many String objects will be created(With explanation please...)
Any help on this will be highly appreciated.
Thanks
-
11-02-2007, 11:36 AM #2
- Join Date
- Nov 2007
- Answers
- 7
Hi.
Am not sure of your question. If you want to know the no of objects created by your class. You can have a counter variable in your constructor that can be just incremented . This will help to find out the no of objects actually created by the class.
-
Hi
String functions always return a new string object after manipulation. So here there are 3 object created.
String s1="abc"; One s1
s1.concat(s1); One return of this
s1.replace('a','z'); One return of this
-
Sponsored Ads

Reply With Quote





