上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页
摘要: 在java IO实际上很好的体现了java的面向对象的设计思想,一个接口或抽象类的具体行为由子类决定,那么根据实例化子类的不同完成的功能也不同,java IO中的所有操作类都放在java.io包中,主要的类和接口是:File,InputStream,OutputStream,Reader,Writer,Serialzable接口File类在整个java.io保重是一个独立的类,此类的主要功能是完成与平台无关的文件操作。在File类中提供了以下的构造方法:public File(String filepath)java中文件路径分隔符使用常量:public static final String 阅读全文
posted @ 2011-01-30 15:41 魔战 阅读(514) 评论(0) 推荐(0) 编辑
摘要: public static Patter compile(String args):通过此方法取得Patter实例,并设置正则 public Matcher matcher(CharSequence input):为Matcher类实例化 public String[] split(CharSequence input):字符串拆分 public String pattern():返回正则表达... 阅读全文
posted @ 2011-01-30 14:12 魔战 阅读(320) 评论(0) 推荐(0) 编辑
摘要: 一,Arraysimport java.util.Arrays;public class ArraysDemo {public static void main(String[] args){int[] i1={1,2,3,4,5,6};int[] i2={6,5,4,3,2,1};//数组排序,默认为升序Arrays.sort(i2);//数组比较System.out.println(Arrays.equals(i1,i2));//将数组i2的内容全部填充为3Arrays.fill(i2,3);//输出数组数据System.out.println(Arrays.toString(i2));} 阅读全文
posted @ 2011-01-29 14:26 魔战 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 克隆就是将一个对象的内容完整的复制下来。Objec类提供以下的方法,完成对象的克隆protected Object clone() throws CloneNotSupportedException对于克隆操作并不是每一个对象都应该具备的,在java中只有部分对象才有可能进行克隆的操作,但是这部分对象必须有一个明确的说明。如果希望被克隆的对象,那么其所在的类必须实现Cloneable接口,该接口没有实现任何方法,只是一个标识接口。class Person implements Cloneable {public Object clone() throws CloneNotSupportedEx 阅读全文
posted @ 2011-01-29 13:51 魔战 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 大数字操作指的是数字非常大的数,大到已经超过了整个数据类型的保存范围,此时就需要使用对象的形式进行操作,BigInteger,BigDecimalBigInteger表示大的整型数据import java.math.BigInteger;public class BigIntegerDemo {public static void main(String args[]){ String num="9999999999999999999999999999999999999999999999999999"; BigInteger big1=new BigInteger(num); BigInteg 阅读全文
posted @ 2011-01-29 13:38 魔战 阅读(371) 评论(0) 推荐(0) 编辑
摘要: NumberFormat是Format的子类,Format三个子类都是与国际化相关的,在NumberFormat中包含一个子类:DecimalFormat,那么通过此类可以完成进一步的数字格式化操作。通过以下方法完成数字的格式化操作:public final String format(double number)通过以下方法取得NumberFormat实例public static final NumberFormat getInstance()import java.text.NumberFormat;public class NumberFormatDemo {public static 阅读全文
posted @ 2011-01-29 12:37 魔战 阅读(2850) 评论(0) 推荐(0) 编辑
摘要: 一,Math类public class MathDemo {public static void main(String args[]){System.out.println("PI="+Math.PI);System.out.println(Math.max(1, 2));//四舍五入System.out.println(Math.round(89.6));}}二,Random类import java.util.Random;public class RandomDemo {public static void main(String args[]){ Random r=new Random 阅读全文
posted @ 2011-01-29 12:19 魔战 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 一,DateFormat与MessageFormat一样都属于Format类的子类,此类专门用于格式化使用,java.util.Date本身已经可以很好的指定出一个具体的日期,但需要用DateFormat进行格式的设置。在DateFormat中存在以下的格式化操作:1,public final String format(Date date),接收Date型数据变为String类型数据取得DateFormat类的实例2,public static final DateFormat getDateInstance(),根据默认环境取得3,public static final DateForma 阅读全文
posted @ 2011-01-22 17:37 魔战 阅读(226) 评论(0) 推荐(0) 编辑
摘要: 一,Demo1public class StringBufferDemo2 { public static void main(String args[]) { StringBuffer buf=new StringBuffer(); buf.append("hello").append(" world!"); System.out.println(buf.toString()); }}二,Demo2public class StringBufferDemo2 { public static void main(String args[]) { StringBuffer buf=new 阅读全文
posted @ 2011-01-22 16:00 魔战 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 在java中有两种方式实现线程,继承Thread类和实现Runnable接口方法一:一个类只要继承了Thread类,同时覆写了run()方法那么就能实现多线程。public class ThreadDemo extends Thread{ private String name; public ThreadDemo(String name) { this.name=name; } public void run() { for(int i=0;i5;i++) System.out.print("Thread运行:"+name+"i-"+i); }}public class Threa 阅读全文
posted @ 2011-01-22 14:36 魔战 阅读(143) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 21 下一页