Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestClass {
- public static void main(String args[]){
- Map<Integer, String[]> myMap=new HashMap<>();
- for(int i=0;i<5;i++){
- int key=i;
- String[] value=new String[]{String.valueOf(i),String.valueOf(i+1),String.valueOf(i+2)};
- myMap.put(key, value);
- }
- for(Map.Entry<Integer, String[]> entry:myMap.entrySet()){
- String[] value=entry.getValue();
- for(String val:value){
- System.err.println("Key="+entry.getKey()+"-Value"+val);
- }
- System.out.println("-------------------------------------");
- }
- }
- }
- Key=0-Value0
- Key=0-Value1
- Key=0-Value2
- -------------------------------------
- Key=1-Value1
- Key=1-Value2
- Key=1-Value3
- -------------------------------------
- Key=2-Value2
- Key=2-Value3
- Key=2-Value4
- -------------------------------------
- Key=3-Value3
- Key=3-Value4
- Key=3-Value5
- -------------------------------------
- Key=4-Value4
- Key=4-Value5
- Key=4-Value6
- -------------------------------------
- Key=0-Value0
- Key=0-Value1
- Key=0-Value2-------------------------------------
- -------------------------------------
- Key=1-Value1
- Key=1-Value2
- Key=1-Value3
- Key=2-Value2
- Key=2-Value3
- Key=2-Value4
- Key=3-Value3
- Key=3-Value4
- -------------------------------------
- Key=3-Value5
- -------------------------------------
- Key=4-Value4
- Key=4-Value5
- Key=4-Value6
- -------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement