java类集合
来源:互联网 发布:手机端图片点击放大js 编辑:程序博客网 时间:2024/06/08 14:10
public class KindMode {
public static void main(String[] args) throws IOException {
//单链表的基本操作
LinkedList link=new LinkedList();
link.add(0, "shxiinfa");
link.add(1,"zhangyan");
link.add(2,"shixiaocun");
link.remove(1);
System.out.println(link);
//和队列是一样的,去除头部
link.pop();
System.out.println(link);
link.peek();
System.out.println(link);
//栈的基本操作
Stack<Integer> stack=new Stack<Integer>();
stack.add(1);
stack.add(2);
stack.add(0,22);
stack.pop();
System.out.println(stack);
//队列的基本操作
//Queue<Integer> queue=new Queue<Integer>();
//link.add(3, "yejianhua");
//link.peek();
// 添加基础类型数据
ArrayList<Integer> list = new ArrayList<Integer>();
int[] a = { 1, 2, 4, 6, 7 };
int[] b = new int[12];
list.add(1);
list.add(2);
System.out.println(list);
// 添加字符串
StringBuffer sb = new StringBuffer();
String s[] = { "shixinfa2", "zhangyan" };
sb.append("shixinfa");
sb.append(s).toString();
System.out.println(sb);
// 往文件中输入字符串
File mkfile = new File("D://bb.txt");
if (!mkfile.exists()) {
mkfile.createNewFile();
}
FileOutputStream input = new FileOutputStream(mkfile);
String context = "this is a page";
byte by[] = new byte[1024];
by = context.getBytes();
input.write(by);
input.close();
BufferedReader reader = null;
try {
System.out.println("以行为单位读取文件内容,一次读一整行:");
reader = new BufferedReader(new FileReader(mkfile));
String tempString = null;
int line = 1;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
System.out.println("line " + line + ": " + tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/*FileInputStream readfile = new FileInputStream(mkfile);
* int recevie; recevie=readfile.read(by); while(recevie!=-1){
* System.out.println(recevie); } readfile.close(); //
int tempbyte;
while ((tempbyte = readfile.read()) != -1) {
System.out.write(tempbyte);
}
readfile.close();
}
*/
//单链表的基本操作
public static void main(String[] args) throws IOException {
//单链表的基本操作
LinkedList link=new LinkedList();
link.add(0, "shxiinfa");
link.add(1,"zhangyan");
link.add(2,"shixiaocun");
link.remove(1);
System.out.println(link);
//和队列是一样的,去除头部
link.pop();
System.out.println(link);
link.peek();
System.out.println(link);
//栈的基本操作
Stack<Integer> stack=new Stack<Integer>();
stack.add(1);
stack.add(2);
stack.add(0,22);
stack.pop();
System.out.println(stack);
//队列的基本操作
//Queue<Integer> queue=new Queue<Integer>();
//link.add(3, "yejianhua");
//link.peek();
// 添加基础类型数据
ArrayList<Integer> list = new ArrayList<Integer>();
int[] a = { 1, 2, 4, 6, 7 };
int[] b = new int[12];
list.add(1);
list.add(2);
System.out.println(list);
// 添加字符串
StringBuffer sb = new StringBuffer();
String s[] = { "shixinfa2", "zhangyan" };
sb.append("shixinfa");
sb.append(s).toString();
System.out.println(sb);
// 往文件中输入字符串
File mkfile = new File("D://bb.txt");
if (!mkfile.exists()) {
mkfile.createNewFile();
}
FileOutputStream input = new FileOutputStream(mkfile);
String context = "this is a page";
byte by[] = new byte[1024];
by = context.getBytes();
input.write(by);
input.close();
BufferedReader reader = null;
try {
System.out.println("以行为单位读取文件内容,一次读一整行:");
reader = new BufferedReader(new FileReader(mkfile));
String tempString = null;
int line = 1;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
System.out.println("line " + line + ": " + tempString);
line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
}
/*FileInputStream readfile = new FileInputStream(mkfile);
* int recevie; recevie=readfile.read(by); while(recevie!=-1){
* System.out.println(recevie); } readfile.close(); //
int tempbyte;
while ((tempbyte = readfile.read()) != -1) {
System.out.write(tempbyte);
}
readfile.close();
}
*/
//单链表的基本操作
阅读全文
1 0
- Java集合:集合类详解
- Java集合-常用集合类
- JAVA【集合一】集合类
- JAVA中的集合类
- JAVA中的集合类
- JAVA中的集合类
- Java集合类(整理)
- java集合类
- JAVA中的集合类
- Java集合类笔记
- JAVA中的集合类
- java集合类
- java集合类总结
- JAVA中的集合类 - -
- JAVA中的集合类
- java集合类
- java 集合类
- java中的集合类
- js正则表达式的基本语法 精华部分,看后即懂
- servlrt中使用内置对象
- R导出excel自动命名sheet --ava.lang.OutOfMemoryError: GC overhead limit exceeded
- 打造属于自己的cnpm/npm安装,生成自定义项目架构
- django发送邮件
- java类集合
- urllib与urllib2的学习总结(python2.7.X)
- expdp 问题和 ORA-00600: internal error code, arguments: [25027], [6], [0], [], [], [], [], [], [], [],
- python .txt文件读取及数据处理总结
- 个人成长与职业规划
- Matlab2012b license失效解决办法
- 自定义View画八卦图
- lucene index
- 数据结构实验之图论七:驴友计划