PrintSream和PrintReader实例

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...
I/O编 | 2010-05-21 14:51 | 阅读 3384 次 | 评论 0 条

InputStreamReader和OutputStreamWriter实例

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(...
I/O编 | 2010-05-21 14:37 | 阅读 1064 次 | 评论 0 条

BufferedReader和BufferedWriter实例

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...
I/O编 | 2010-05-21 14:31 | 阅读 850 次 | 评论 0 条

FileReader/FileWriter的实例

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 ) { ...
I/O编 | 2010-05-21 14:22 | 阅读 918 次 | 评论 0 条

FileInputStram/FileOutputStream的实例

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...
I/O编 | 2010-05-21 14:13 | 阅读 841 次 | 评论 0 条

集合综合理论编

讲述的是集合一章中的内容Set:不区分元素的顺序,不允许出现重复的值list:区分元素的顺序,且允许出现重复的值map:采用key——values的,不允许有重复的键,每个键最多对应一个值java集合只能保存引用类型的数据,是对象的引用Collection接口描述set和list集合类型的根接口相关方法: add()如果增加重复元素,则增加失败,返回false contains()判断是否包含有某个元素 iterator()返回成一个迭代器List可以对元素的插入位置进...
集合 | 2010-05-21 11:08 | 阅读 852 次 | 评论 0 条

Arrays的实例

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(...
集合 | 2010-05-21 11:07 | 阅读 766 次 | 评论 0 条

shuffle数字混排

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...
集合 | 2010-05-21 11:00 | 阅读 981 次 | 评论 0 条

TestCollections实例

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); ...
集合 | 2010-05-21 10:56 | 阅读 843 次 | 评论 0 条

HashMap的应用

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)...
集合 | 2010-05-21 10:39 | 阅读 1080 次 | 评论 0 条

Comparable实例

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...
集合 | 2010-05-21 10:27 | 阅读 1065 次 | 评论 1 条

TreeS用的相关实例

import java.util.TreeSet;import java.util.Iterator;public class TestTreeSet{ public static void main(String[] args) { TreeSet ts = new TreeSet(); ts.add("orange"); ts.add("banana"); ts.add("apple"); ts.add("grape"); Iterator it = ts.iterator(); ...
集合 | 2010-05-21 10:13 | 阅读 785 次 | 评论 0 条

hashset的实例

package com.yds.review.list11;import java.util.Date;import java.util.HashSet;import java.util.Iterator;public class TestHashSet{ public static void main(String[] args) { HashSet h = new HashSet(); h.add("1st"); h.add("2nd"); h.add(new Integer(3)); h.add(new...
集合 | 2010-05-21 10:05 | 阅读 945 次 | 评论 0 条

Iterator

import java.util.Date;import java.util.ArrayList;import java.util.Vector;import java.util.Iterator;public class TestIterator{ public static void main(String[] args) { ArrayList a = new ArrayList(); a.add("China"); a.add("USA"); a.add("Korea"); Iterator it...
集合 | 2010-05-21 09:58 | 阅读 799 次 | 评论 0 条

stack的实例

import java.util.Date;import java.util.Stack;public class TestStack{ public static void main(String[] args) { Stack s = new Stack(); s.push("hello"); s.push(new Date()); s.push(400); //自动封装,等价于s.push(new Integer(400)); s.push(3.14); System.o...
集合 | 2010-05-21 09:51 | 阅读 849 次 | 评论 0 条

vector实例

package com.yds.review.list11;import java.util.Date;import java.util.Vector;public class TestVector{ public static void main(String[] args) { Vector v = new Vector(); v.add("1st"); v.add("2nd"); v.add(new Integer(3)); v.add(new Double(4.0)); v.add("2...
集合 | 2010-05-21 09:44 | 阅读 982 次 | 评论 0 条

第一个实例

package com.yds.review.list11;import java.util.Date;import java.util.ArrayList;public class TestArrayList{ public static void main(String[] args) { ArrayList h = new ArrayList(); h.add("1st"); h.add("2nd"); h.add(new Integer(3)); h.add(new Double(4.0)); ...
集合 | 2010-05-21 09:42 | 阅读 861 次 | 评论 0 条

第一个Swing程序

package com.yds.gui.applet;import java.awt.Color;import java.awt.Container;import java.awt.GridLayout;import javax.swing.JFrame;import javax.swing.JLabel;public class JFtext1 { /** * @param args */ public static void main(String[] args) { JFrame jf=new JFrame(); Cont...
awt和Sring | 2010-05-20 20:24 | 阅读 909 次 | 评论 0 条

打开文件对话框和保存文件对话框

package com.yds.gui.fourpart;import java.awt.Button;import java.awt.FileDialog;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class FileSave implements ActionListener{ Button b1,b2; FileDialog f_open,f_save; Frame f; public void Ui(){...
awt和Sring | 2010-05-20 16:43 | 阅读 1048 次 | 评论 0 条

有子窗口的应用

import java.awt.*;import java.awt.event.*;public class TestDialog implements ActionListener{ private Label info; private Dialog loginDialog; private Dialog quitDialog; private TextField tf_name; private TextField tf_psw; public static void main( String args[]) { new Tes...
awt和Sring | 2010-05-20 16:14 | 阅读 817 次 | 评论 0 条
浏览274709次