Results 1 to 5 of 5
- 03-28-2009, 03:24 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
How to count the number of specific object in a Vector collection?
Dear All
I am rather new to Java and have been stuck for hours trying to figure out one thing:
I have a collection of different objects in a Vector<IObject> (all of these objects implement an interface I created called IObject).
How can I count the number of specific objects in my collection?
Let's say I have objects A,B,C that implements IObject, and objects D,E that inherit from C (and thus also implement IObject).
I imagine a function like:
int getObjectCount(String classNameString)
{ }
which would return the count of objects named classNameString.
However, if I have, say, two objects D and two objects E in my collection and then call getObjectCount(C.class.getSimpleName()) it must return '4'. (Because C is a supertype of D and E).
Any ideas? I am slowly losing my will to live with this problem...:(
Thanks a lot!;)
-
- 03-28-2009, 03:55 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 2
- Rep Power
- 0
Fubarable
Any logical fallacy detected by you due to me posting on two different forums?
-
Please see my discussion in (one of ?) the cross-post(s?).
-
Similar Threads
-
[SOLVED] How to count the number of words in a string
By andy5605 in forum New To JavaReplies: 8Last Post: 02-04-2009, 08:55 PM -
Either ResultSet or a specific object?
By saul_2110 in forum JDBCReplies: 3Last Post: 12-06-2008, 07:41 AM -
How setting an Object to null help Garbage Collection?
By piyu.sha in forum Advanced JavaReplies: 3Last Post: 10-06-2008, 07:35 AM -
Search a object in a vector
By TalhaS in forum New To JavaReplies: 2Last Post: 04-30-2008, 02:05 PM -
How to cast an Object into a specific type (Integer/String) at runtime
By mailtogagan@gmail.com in forum Advanced JavaReplies: 2Last Post: 12-03-2007, 01:04 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks