Key-Value是用一个不可重复的key集合对应可重复的value集合。(典型的例子是字典:通过页码的key值找字的value值)。
例子:
key1—value1;
key2—value2;
key3—value3.
SortedMap:如果一个Map可以根据key值排序,则称其为SortedMap。(如字典)
!!注意数组和集合的区别:数组中只能存简单数据类型。Collection接口和Map接口只能存对象。
1 1 package TomTexts; 2 2 3 3 4 4 public class TomTexts_04 { 5 5 public static void main(String[] args) { 6 6 String s1="aaaa"; 7 7 String s2="aaaa"; 8 8 String s3="AAAA"; 9 9 String s4="bcd"; 1010 if (s1.equals(s2)) { 1111 System.out.println("s1==s2"); 1212 } 1313 else { 1414 System.out.println("s1!=s2"); 1515 } 1616 if (s1.equalsIgnoreCase(s3)) { 1717 System.out.println(" s1= =s3 when ignoring case"); 1818 } 1919 else { 2020 System.out.println(" s1!=s3 when ignoring case"); 2121 } 2222 if (s1.regionMatches(true,0,s3,1,3)) { 2323 System.out.println(" s1= =s3 when ignoring case"); 2424 } 2525 else { 2626 System.out.println(" s1!=s3 when ignoring case"); 2727 } 2828 if (s1.regionMatches(false,0,s3,1,3)) { 2929 System.out.println(" s1= =s3 when not ignoring case"); 3030 } 3131 else { 3232 System.out.println("s1!=s3 when not ignoring case"); 3333 } 3434 if (s1.compareTo(s4)<0) { 3535 System.out.println(" s1<s4"); 3636 } 3737 else if (s1.compareTo(s4)==0){ 3838 System.out.println("s1= =s4"); 3939 } 4040 else { 4141 System.out.println("s1>s4"); 4242 } 4343 } 4444 }