Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in Java only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
Java
How many objects are created for a particular class how to find?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
thulaseeram
New Member
Join Date:
Sep 2006
Posts:
23
#1
How many objects are created for a particular class how to find?
Feb 12 '08, 10:44 AM
Hi,
How to find out, the number of objects created to a particular class.
Thanks,
Ram
r035198x
MVP
Join Date:
Sep 2006
Posts:
13225
#2
Feb 12 '08, 10:51 AM
Originally posted by
thulaseeram
Hi,
How to find out, the number of objects created to a particular class.
Thanks,
Ram
You could use a static variable to count them every time they are created in an instance
initializer
Comment
Post
Cancel
rameshwar8787
New Member
Join Date:
Mar 2010
Posts:
1
#3
Mar 31 '10, 02:31 AM
Count Number of Object Created for a Class
class One
{
static int count = 0;
One()
{
count++;
System.out.prin tln("Number of Object created :"+count);
}
public static void main(String[] args)
{
new One();
new One();
new One();
new One();
One o = new One();
}
}
Comment
Post
Cancel
jkmyoung
Recognized Expert
Top Contributor
Join Date:
Mar 2006
Posts:
2057
#4
Mar 31 '10, 01:23 PM
Are you talking about the number of objects of that class, or internal class members?
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment