package hashmap_1;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// HashMap<String,double> hashMap = new
// HashMap<String,double>();///Syntax error on token "double",
// Dimensions expected after this token
HashMap<String, Double> hashMap = new HashMap<String, Double>();
hashMap.put("aa", 90.0);
hashMap.put("bb", 80.0);
hashMap.put("cc", 70.0);
Iterator iter = hashMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
Object key = entry.getKey();
Object value = entry.getValue();
System.out.println(key + ":" + value);
}
char a='a';
char b= 'c';
if(a!=b){ //char型字符可以直接用==比较是否相同
System.out.println(true);
}
String str = "abcd";
System.out.println(str.charAt(0));
System.out.println(str.charAt(str.length()-1));
System.out.println(str.substring(str.length()-2, str.length()-1));
System.out.println(str.substring(0, str.length()));
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(23);
list.add(26);
list.set(0, 11);
Iterator it= list.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
}
aa:90.0
bb:80.0
cc:70.0
true
a
d
c
abcd
11
26