How to make ArrayList that work as two dimentional array in java?

后端 未结 7 1570
时光说笑
时光说笑 2021-01-23 20:16

I want to make arrayList object in java that work as two dimentional array. My question is how can we access value from specific dimention from arrayList.

in two diment

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-23 21:03

    You mean something like a List in a List??

    May be something like...

    List> twoDList = new ArrayList<>();
    

    i want to make a List, in which each List key contains another List inside it

    It should more like you want some kind of Map, which is basically a key/value pair.

    Map> mapValues = new HashMap<>(25);
    List listOfValues = ...;
    //...
    mapValues.put("A unique key for this list", listOfValues);
    
    //...
    
    List thatListOfValues = mapValues.get("A unique key for this list");
    

提交回复
热议问题