详细的键值总结
public class shujub {
public static void main(String[] args) {
LinkedList<String> lList = new LinkedList<String>();
lList.add("1");lList.add("a");lList.add("3");lList.add("d");
lList.add("5");lList.add("f");
System.out.println("链表的第一个元素是 : " + lList.getFirst());//1
System.out.println("链表最后一个元素是 : " + lList.getLast());//d
for (String str: lList)
System.out.println(str);
List subl = lList.subList(1,4);//获取第1,2,3共三个元素。从0开始。
System.out.println(subl);
subl.remove(2);
System.out.println(subl);System.out.println(lList);
lList.addFirst("X");lList.addLast("Z"); lList.removeFirst();
//containKey(key); containValue(value);如包含指定的键(值)返回true
//get(key);返回指定键值对应的值 isEmpty 为空返回true
//map.put("语文",80.0) 添加对应的键和值。 remove("数学",89.0)
//size();个数。
System.out.println("***HashMap***");//在HashMap中的对象是无序的
HashMap<String,Double> map = new HashMap<String,Double>();
map.put("语文",80.0);map.put("数学",89.0);map.put("英语",78.2);
Double sum = 0.0;
for (Iterator<String> i = map.keySet().iterator(); i.hasNext();) {
String key = i.next();
Double value = map.get(key);
System.out.println(key+":"+value);
sum += value;
}
}
}
public class ConfigFileReadUtil {
public static void main(String arg[]) throws IOException{
Properties p = new Properties();
p.load(ClassLoader.getSystemResourceAsStream("config/cardlist.properties"));
//有六种方法读取文件,这是其中一种。
Enumeration<String> en = (Enumeration<String>) p.propertyNames();//得到配置文件的名字
int i=0;
while (en.hasMoreElements()) {
if(i==0){
i++;en.nextElement();
}
if(i>0){
String key = (String) en.nextElement();
String Property = p.getProperty(key);
System.out.println(key + "=" + Property);//键值和属性值一一对应
}
}
Properties pps = new Properties();//写 properties
InputStream in = new FileInputStream("D:/sgs/Test.properties"); //从输入流中读取属性列表(键和元素对)
pps.load(in);//调用 Hashtable 的方法 put。使用 getProperty 方法提供并行性。
//强制要求为属性的键和值使用字符串。返回值是 Hashtable 调用 put 的结果。
OutputStream out = new FileOutputStream("D:/sgs/Test.properties");
pps.setProperty("long", "212,213,215");//以适合使用 load 方法加载到 Properties 表中的格式,
//将此 Properties 表中的属性列表(键和元素对)写入输出流
pps.store(out, "Update " + "long" + " name");
}
}
public class Creatxml {
public static voi
d main(String[] args) {
Document doc = DocumentHelper.createDocument();
// doc.addProcessingInstruction("xml-stylesheet", "t