常用单词的拼写和特殊方法

[1] long t1 = System.currentTimeMillis();
    System.currentTimeMillis();
    输出从1970年1月1日到程序运行到本行为止所经历的时间(单位:ms)
    接受数据的变量一般定义为long类型(使数值足够的大,以免超出数据范围)

[2]String word = JOptionPane.showInputDialog(null,"请输入您要检查的单词:");
    在屏幕中央输出对话框,并显示“请输入您要检查的单词”
[3]Iterator 迭代器  使用方法如下
    for(Iterator<Teacher> car = etoak.iterator(); car.hasNext();){
        Teacher x = car.next();
        //自带有一个remove()删除方法
        car.remove();
    }
[4]instanceof 判断一个元素是不是属于另一个类
    具体用法
    if(!(obj instanceof Teacher))return false;
[5]Interfance 接口
[6]不要在压缩包里面运行程序
[7]从txt文档中读取数据    
    FileReader fr = new FileReader("EtoakWords.txt");//针头
    BufferedReader br = new BufferedReader(fr);//针管
    String str;
[8]删除某一类型的文件(.class)
import java.io.*;
public class Delete{
    public static void main(String[] args)throws Exception{
        Thread.sleep(5000);
        File dir = new File(".");
        File[] fs = dir.listFiles(x -> x.getName().toLowerCase().endsWith(".class"));
        for(File f : fs){
            f.delete();
        }
    }
}
[9]千万不要忘记导包
[10]关于数组的一些方法
        System.arraycopy(1,2,3,4,5);
        Arrays.sort();
        Math.random();
[11]JDK5.0开始Collections.synchronizedMap(map);将HashMap转换成线程安全的集合
    并且效率比Hashtable效率高
    同样JDK5.0开始Collections.synchronizedList(List);将List转换成线程安全的集合
    效率比Vector高
    
[12]查看系统环境
    Properties properties = System.getProperties();
    Enumeration propertyNames = properties.propertyNames();
    while(propertyNames.hasMoreElements()){
        String key = (String) propertyNames.nextElement();
        String value = System.getProperty(key);
        System.out.println(key + "--->" + value);
    }
[13]在同一个文件夹的两个.java文件中有同名类,后一个编译时会覆盖前一个生成的.class
文件,文件夹中只有一个本类名.class文件。    

[14]打开程序
    //打开文本文档
    Runtime.getRuntime().exec("notepad");//exec()方法里面抛了异常
    //打开画图工具
    Runtime.getRuntime().exec("mspaint");
[15]Runtime用于表示虚拟机运行时的状态


    Runtime run = Runtime.getRuntime();
    System.out.println("处理器的个数:" + run.availableProcessors() + "个");
    System.out.println("空闲内存数量:" + run.freeMemory() /1024 / 1024 + "M");
    System.out.println("最大可用内存数量:" + run.maxMemory() /1024 /1024 + "M");

[16]Math类的应用

    System.out.println("计算绝对值的结果" + Math.abs(-1));
    System.out.println("求大于参数的最小整数" + Math.ceil(5.6));
    System.out.println("求小于参数的最大整数" + Math.floor(-4.2));
    System.out.println("对小数进行四舍五入的结果" + Math.round(-4.6));
    System.out.println("求两个数的较大值" + Math.max(2.1,-2.1));
    System.out.println("求两个数的较小值" + Math.min(2.1,-2.1));
    System.out.println("生成一个大于等于0.0小于1.0的随机值" + Math.random());

[17]Random随机数产生(有参和无参)
    Random r = new Random(78);每次运行产生随机序列是相同的
    Random r = new Random();每次运行产生的序列都不相同

[18]包装类
    int ===  Integer    char === Character

[19]时间戳
    System.out.println(new Date());打印当前时间
    System.out.println(new Date(888888888888888L));
    打印1970年0月0日0时0分0秒经过888888888888888毫秒后的时间

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值