在java中创建字符串列表,其中每个字符串都是元组列表(作为值)的键
如何创建一个字符串列表,其中每个字符串指向一个元组列表;换句话说,每个字符串都是元组列表的键(作为值) 每个元组的格式应为:在java中创建字符串列表,其中每个字符串都是元组列表(作为值)的键,java,list,data-structures,map,hashmap,Java,List,Data Structures,Map,Hashmap,如何创建一个字符串列表,其中每个字符串指向一个元组列表;换句话说,每个字符串都是元组列表的键(作为值) 每个元组的格式应为: List<String> pref, where each element of the list pref (say pref_i): pref1 --> {(T1:10),(T2:13), T3:3),...} pref2 --> {(T1:7), (T4:3), (T5:1),...} pref3 --> ... List pref,
List<String> pref, where each element of the list pref (say pref_i):
pref1 --> {(T1:10),(T2:13), T3:3),...}
pref2 --> {(T1:7), (T4:3), (T5:1),...}
pref3 --> ...
List pref,其中List pref的每个元素(比如pref_i):
pref1-->{(T1:10),(T2:13),T3:3),…}
pref2-->{(T1:7),(T4:3),(T5:1),…}
pref3-->。。。
多地图救援
java中没有touples,除非您模拟它们。
多重映射就像有一个映射,其中键是字符串,值是元素数组
多地图救援 java中没有touples,除非您模拟它们。 多重映射就像有一个映射,其中键是字符串,值是元素数组
在我看来,您需要一个
映射,具体取决于元组的类型(此处假设为字符串):
Map prefs=新HashMap;
你可以让你的元组是任何类型的,为了方便我使用了字符串
如果通过集合
或映射
可以更好地表示元组,请相应地更改它。在我看来,您需要一个映射
,具体取决于元组的类型(此处假设一个字符串):
Map prefs=新HashMap;
你可以让你的元组是任何类型的,为了方便我使用了字符串
如果通过集合
或映射
更好地表示元组,请相应地更改它。也许您可以使用HashMap的HashMap?第一个HashMap用于使用字符串键,第二个HashMap用于元组
HashMap<String, HashMap<String, String>> myHashMap = new HashMap<String, HashMap<String, String>>();
HashMap myHashMap=newhashmap();
希望这有帮助!再见 也许你可以使用HashMap的HashMap?第一个HashMap用于使用字符串键,第二个HashMap用于元组
HashMap<String, HashMap<String, String>> myHashMap = new HashMap<String, HashMap<String, String>>();
HashMap myHashMap=newhashmap();
希望这有帮助!再见 您还可以使用列表
import java.util.ArrayList;
import java.util.List;
public class TestArrayList {
public static void main(String[] args) {
List<String> tempList=new ArrayList<String>();
List<String> temp1=new ArrayList<String>();
temp1.add(0, "a");
temp1.add(1, "b");
List<String> temp2=new ArrayList<String>();
temp2.add(0, "c");
temp2.add(1, "d");
List<String> temp3=new ArrayList<String>();
temp3.add(0, "e");
temp3.add(1, "f");
tempList.addAll(0, temp1);
tempList.addAll(1, temp2);
tempList.addAll(1, temp3);
for(int i=0;i<tempList.size();i++){
System.out.println(">>"+tempList.get(i));
}
}
}
import java.util.ArrayList;
导入java.util.List;
公共类测试列表{
公共静态void main(字符串[]args){
List templast=new ArrayList();
List temp1=new ArrayList();
temp1.添加(0,“a”);
第1段.加入(1,“b”);
List temp2=new ArrayList();
第2段加入(0,“c”);
第2节添加(1,“d”);
List temp3=new ArrayList();
temp3.添加(0,“e”);
第3节添加(1,“f”);
圣堂武士。addAll(0,temp1);
圣堂武士。阿达尔(1,temp2);
圣堂武士。阿达尔(1,temp3);
对于(inti=0;i您也可以使用List
import java.util.ArrayList;
import java.util.List;
public class TestArrayList {
public static void main(String[] args) {
List<String> tempList=new ArrayList<String>();
List<String> temp1=new ArrayList<String>();
temp1.add(0, "a");
temp1.add(1, "b");
List<String> temp2=new ArrayList<String>();
temp2.add(0, "c");
temp2.add(1, "d");
List<String> temp3=new ArrayList<String>();
temp3.add(0, "e");
temp3.add(1, "f");
tempList.addAll(0, temp1);
tempList.addAll(1, temp2);
tempList.addAll(1, temp3);
for(int i=0;i<tempList.size();i++){
System.out.println(">>"+tempList.get(i));
}
}
}
import java.util.ArrayList;
导入java.util.List;
公共类测试列表{
公共静态void main(字符串[]args){
List templast=new ArrayList();
List temp1=new ArrayList();
temp1.添加(0,“a”);
第1段.加入(1,“b”);
List temp2=new ArrayList();
第2段加入(0,“c”);
第2节添加(1,“d”);
List temp3=new ArrayList();
temp3.添加(0,“e”);
第3节添加(1,“f”);
圣堂武士。addAll(0,temp1);
圣堂武士。阿达尔(1,temp2);
圣堂武士。阿达尔(1,temp3);
对于(int i=0;i