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));//四舍五入 } }
原文:https://www.cnblogs.com/linding/p/13493324.html