Create an ArrayList with multiple object types?

前端 未结 12 2593
抹茶落季
抹茶落季 2020-12-08 01:57

How do I create an ArrayList with integer and string input types? If I create one as:

List sections = new ArrayList 

        
12条回答
  •  忘掉有多难
    2020-12-08 02:31

    You can make it like :

    List sections = new ArrayList ();
    
    
    

    (Recommended) Another possible solution would be to make a custom model class with two parameters one Integer and other String. Then using an ArrayList of that object.

    提交回复
    热议问题