摘要: 一,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 魔战 阅读(329) 评论(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) 编辑