Results 1 to 7 of 7
Thread: Generic method
- 01-17-2011, 12:13 PM #1
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
- 01-17-2011, 12:23 PM #2
Hi.
You can't create new instance from generic type, because may be situation when generic type may be have no public constructors.
- 01-17-2011, 12:25 PM #3
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
thanks petr,
also we cant assure that the generic type have a constructor of the type we use
- 01-17-2011, 01:11 PM #4
However, I read about this problem. You can use (Class<E> clazz).newInstance();,
but it makes no sense.
- 01-17-2011, 01:14 PM #5
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
think its using reflection ...
right?
- 01-17-2011, 01:20 PM #6
Yes,it is. This is reflection.
I don't understand why do you want to do this? Why do you want to use this code?
- 01-18-2011, 05:51 AM #7
Member
- Join Date
- May 2010
- Posts
- 90
- Rep Power
- 0
Similar Threads
-
Generic Classes
By marciojc in forum New To JavaReplies: 0Last Post: 12-17-2010, 11:34 PM -
Generic method problem
By counterfox in forum New To JavaReplies: 6Last Post: 10-24-2010, 06:30 PM -
generic code
By mac in forum New To JavaReplies: 4Last Post: 05-27-2010, 05:06 PM -
standard input stream storing to a generic method?
By vendetta in forum New To JavaReplies: 3Last Post: 01-29-2010, 08:13 PM -
generic types
By jon80 in forum New To JavaReplies: 6Last Post: 06-12-2009, 10:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks