手机版

C++键值总结(2)

时间:2025-04-22   来源:未知    
字号:

详细的键值总结




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

…… 此处隐藏:190字,全部文档内容请下载后查看。喜欢就下载吧 ……
C++键值总结(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)