※ 此程式碼並非優化版本,僅供個人學習用途,若有任何問題請告知。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
public class simplecol { | |
public static void main(String[] args) { | |
List l = new ArrayList(); | |
l.add(2); | |
l.add(4); | |
l.add(6); | |
System.out.println("List的內容為: "+l); | |
Map<Integer, String> m = new HashMap<>(); | |
m.put(0, "a"); | |
m.put(1, "b"); | |
m.put(2, "c"); | |
System.out.println("Map的內容為: "+m); | |
} | |
} |
List的內容為: [2, 4, 6] Map的內容為: {0=a, 1=b, 2=c}
沒有留言:
張貼留言