摘要: 利用随机函数创建一个不重复的数组 import java.util.Random; //导入的随机函数类 public class RandomTest { public static void main(String[] args) { Random random = new Random(); //随机函数Random int[ 阅读全文
posted @ 2022-05-10 10:47 ZephyrLux 阅读(261) 评论(1) 推荐(0)
摘要: 二分法查找案例 public class BinarySearch { public static int binarySearch(int[] arr, int num) { int start = 0; //起始下标 int end = arr.length - 1; //数组末下标 while(start < 阅读全文
posted @ 2022-05-07 12:04 ZephyrLux 阅读(114) 评论(0) 推荐(0)
摘要: 自定义异常 class MyException extends Exception { //自定义异常继承Exception类 public MyException(String msg) { //调用父类构造方法传递“异常信息” super(msg); }} public class ExceptionTes 阅读全文
posted @ 2022-05-07 12:04 ZephyrLux 阅读(56) 评论(0) 推荐(0)