一路繁花似锦绣前程
失败的越多,成功才越有价值

导航

 
public class Usuallyclass {
    public static void main(String[] args) {
//        控制台输入
//        Scanner scanner = new Scanner(System.in);
//        int i = scanner.nextInt();
//        System.out.println("刚才输入的数字是:"+i);

//        随机数生成
//        Random random = new Random();
//        System.out.println(random.nextInt(10));//[0,10)

//        遍历
//        ArrayList<String> strings = new ArrayList<>();
//        strings.add("linlong");
//        strings.add("dingcaiyan");
//        strings.add("linjincheng");
//        for (int i = 0; i < strings.size(); i++) {
//            System.out.println(strings.get(i));
//        }

//        字符串操作
//        String str = "linlong";
//        System.out.println("LINLONG".equalsIgnoreCase(str));
//        System.out.println(str.substring(3, str.length()));//左开右闭
//        System.out.println(str.replaceAll("l", "g"));
//        String[] ls = str.split("l");
//        for (int i = 0; i < ls.length; i++) {
//            System.out.println(i + ":" + ls[i]);
//        }

//        数组工具类
//        int[] arr = {5, 8, 3, 4, 9, 2, 7, 6, 1};
//        System.out.println(Arrays.toString(arr));
//        Arrays.sort(arr);
//        System.out.println(Arrays.toString(arr));

//        数学工具类
        double num = -6.18;
        System.out.println(Math.abs(num));//绝对值
        System.out.println(Math.ceil(num));//向上取整
        System.out.println(Math.floor(num));//向下取整
        System.out.println(Math.round(num));//四舍五入
    }
}

 

public class UsusallyUseClass {
    public static void main(String[] args) throws ParseException {
//        日期操作
//        long currentTimeMillis = System.currentTimeMillis();
//        Date date = new Date(System.currentTimeMillis() - (1000L * 60 * 60 * 24 * 365));
//        String format = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
//        Date parse = new SimpleDateFormat("yyyy-MM-dd").parse("2020-08-14");

//        日历操作
//        Calendar calendar = Calendar.getInstance();
//        Date date = calendar.getTime();
//        int year = calendar.get(Calendar.YEAR);
//        calendar.set(Calendar.YEAR, 2019);
//        calendar.add(Calendar.YEAR, -1);

//        数组复制
//        int[] ints = {5, 8, 3, 4, 9, 2, 7, 6, 1};
//        int[] intscopy = new int[ints.length];
//        System.arraycopy(ints, 0, intscopy, 0, ints.length);
//        System.out.println(Arrays.toString(intscopy));

//        字符串缓冲区
//        StringBuilder stringBuilder = new StringBuilder("hello");
//        StringBuilder append = stringBuilder.append(" world");
//        System.out.println(append.toString());
//        System.out.println(append == stringBuilder);

//        字符串转数字
        int parseInt = Integer.parseInt("1994");
        Integer integer = Integer.valueOf("2001");
    }
}

 

// 参数验证是否为空
// String field = null;
// Objects.requireNonNull(field, "传递的对象为空");

// 判断末尾字符串
// System.out.println("aaabbbcccddd".endsWith("ddd"));

//编码
//URLEncoder.encode(String, "utf-8");
//解码
//URLDecoder.decode(String, "utf-8");

 

posted on 2020-08-12 22:11  一路繁花似锦绣前程  阅读(126)  评论(0编辑  收藏  举报