关键字: jdk
1.ArrayList是实现了基于动态数组的数据结构,LinkedList基于链表的数据结构。 2.对于随机访问get和set,ArrayList觉得优于LinkedList,因为LinkedList要移动指针。 3.对于新增和删除操作add和remove,LinedList比较占优势,因为ArrayList要移动数据。 这一点要看实际情况的。若只对单条数据插入或删除,ArrayList的速度反而优于LinkedList。但若是批量随机的插入删除数据,LinkedList的速度大大优于ArrayList. 因为ArrayList每插入一条数据,要移动插...
Struts 2 + Spring 2.0 + Hibernate 3.0整合笔记1. 添加Spring 2.0的Libraries选择以下4个jar,并配置到/WEB-INF/lib下Spring2.0 AOP LibrariesSpring2.0 Core LibrariesSpring2.0 Persistence Core LibrariesSpring2.0 WEb Libraries同时,将applicationContext.xml配置到WEB/INF下面。2. 添加Hibernate 3.0的Libraries选择以下2个jar,并配置到/WEB-INF/lib下Hibe...
本次复习的是I/O(输入/出)(总体的复习) InputStream输入流/OutputStream输出流 Node Stream节点流 /Processing Stream处理流 Character Stream 字符流/Byte Stream字节流按照数据流动的方法:有输入流和输出流 输入流只能读取数据,不能写出数据 输出流只能写出数据,不能读入数据 除了RandomAccessFile类(即可读也可写)按照数据流所关联的...
import java.io.*;import java.awt.event.*;import javax.swing.*;
public class TestTempFile implements ActionListener{ private File tempPath; public static void main(String args[]){ TestTempFile ttf = new TestTempFile(); ttf.init(); ttf.createUI(); } public void createUI(){ JFrame frame = new ...
import java.io.File;import java.io.IOException;import java.io.RandomAccessFile;public class TestRandomAccessFile{ private File file; public static void main(String[] args){ TestRandomAccessFile traf = new TestRandomAccessFile(); traf.init(); traf.record("Billy",22); ...
import java.io.*;import java.util.Date;public class TestSetOutput{ public static void main(String[] args){ PrintStream ps = null; PrintStream ps_error = null; try{ ps = new PrintStream(new FileOutputStream("output.txt",true)); System.setOut(ps);//设置...
import java.io.*;public class TestSetInput{ public static void main(String[] args){ try{ //FileInputStream fis = new FileInputStream("source.txt"); //System.setIn(fis); 如果取消了这里的,将在下面的System.io是文件中的内容 int avg = 0; int total = 0; ...
import java.io.*;public class TestCharArrayReader{ public static void main(String[] args){ char[] b = {'I',' ','a','m',' ','S','a','i','l','i','n','g','!'}; CharArrayReader car = new CharArrayReader(b); MyReader mr = new MyReader(); mr.getInfo(car); } }~...
import java.io.*;public class Test{ public static void main(String args[]){ try{ FileOutputStream fos; DataOutputStream dos; FileInputStream fis; DataInputStream dis; fos = new FileOutputStream("myfile.data"); dos = new...
import java.io.*;
public class TestWriteFile{ public static void main (String[] args) { File file = new File("tt.txt"); try { InputStreamReader is = new InputStreamReader(System.in); BufferedReader in=new BufferedReader(is); PrintWriter out = new PrintWriter(new FileWriter(file)); St...
import java.io.InputStreamReader;import java.io.BufferedReader;import java.io.IOException;public class TestStandardInput{ public static void main (String args[]) { String s; InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(...
import java.io.*;public class Test { public static void main(String[] args) { try { FileReader input = new FileReader("Test.java"); BufferedReader br = new BufferedReader(input); FileWriter output = new FileWriter("temp.txt"); BufferedWriter...
import java.io.*;public class Test { public static void main(String[] args) { try { FileReader input = new FileReader("a.txt"); FileWriter output = new FileWriter("temp.txt"); int read = input.read(); while ( read != -1 ) { ...
import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class CopyFile{ public static void main(String[] args) { try { FileInputStream fis = new FileInputStream ("a.jpg");//本地中存在的文件 FileOutputStream fos = new FileOutputStrea...
讲述的是集合一章中的内容Set:不区分元素的顺序,不允许出现重复的值list:区分元素的顺序,且允许出现重复的值map:采用key——values的,不允许有重复的键,每个键最多对应一个值java集合只能保存引用类型的数据,是对象的引用Collection接口描述set和list集合类型的根接口相关方法: add()如果增加重复元素,则增加失败,返回false contains()判断是否包含有某个元素 iterator()返回成一个迭代器List可以对元素的插入位置进...
import java.util.List;import java.util.Arrays;public class TestArrays{ public static void main(String[] args) { Integer[] a = {3,25,12,79,48}; System.out.println(a); System.out.println(Arrays.toString(a)); Arrays.sort(a); System.out.println(Arrays.toString(...
import java.util.ArrayList;import java.util.Collections;public class Game{ ArrayList cards; public static void main(String[] args) { Game g = new Game(); g.deal(); g.display(); } public ArrayList deal(){ if(cards == null){ cards = new Array...
import java.util.Vector;import java.util.ArrayList;import java.util.Collections;import java.util.Enumeration;public class TestCollections{ public static void main(String[] args) { ArrayList alist = new ArrayList(); alist.add(75); alist.add(38); alist.add(21); ...
import java.util.Set;import java.util.HashMap;import java.util.Collection;import java.util.Iterator;public class TestHashMap{ public static void main(String[] args) { HashMap hm = new HashMap(); hm.put(new Integer(1003),new Person(1003,"张三",15)); hm.put(new Integer(1008)...
import java.util.TreeSet;import java.util.Iterator;public class TestComparable{ public static void main(String[] args) { TreeSet ts = new TreeSet(); ts.add(new Person(1003,"张三",15)); ts.add(new Person(1008,"李四",25)); ts.add(new Person(1015,"王五",73)); ts.add...