void Parse (ArrayList list)
{
/ / How to get the passed list element type , then instantiate element ( assuming elements have a default constructor )
...
}
------ Solution ----------------------------------- ---------
obj.getClass (). getSimpleName ()
judge or use instanceof Object
------ Solution ------------------------------ --------------
why this design ah , to find an architect to help you plan the next
------ Solution --------- -----------------------------------
essentially get the generic type
See http://lorry1113.iteye.com/blog/973903
------ For reference only ------------------ ---------------------
No way , the function does not know the type of the list , so you can not use instanceof,
list object obj.getClass (). getSimpleName () returns ArrayList, not an element of the class name information
------ For reference only ------ ---------------------------------
No way , the function does not know the type of the list , so you can not use instanceof,
list object obj.getClass (). getSimpleName () returns ArrayList, not an element of the class name information
list.get (0) ah , like this take ah
------ For reference only ---------------------- -----------------
No way , the function does not know the type of the list , so you can not use instanceof,
list object obj.getClass (). getSimpleName () returns ArrayList, not an element of the class name information
list.get (0) ah , like this take ah
not to die , a start list is empty , my function is to complete the list elements fill.
------ For reference only -------------------------------------- -
wanted to write a json object automatically decomposed into class module
------ For reference only ---------------------- -----------------
very classic , I quest is this code, thank you
没有评论:
发表评论