1. 程式人生 > 實用技巧 >java常用類

java常用類

package A01usuallyclass;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

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));//四捨五入 } }