12 2020 档案

摘要:1 public class Demo13{ 2 3 /* 4 5 NullPointerException即空指针异常,俗称NPE。如果一个对象为null,调用其方法或访问其字段就会产生NullPointerException,这个异常通常是由JVM抛出的 6 7 */ 8 public stat 阅读全文
posted @ 2020-12-29 15:34 dog_IT 阅读(343) 评论(0) 推荐(0)
摘要:1 public class Demo13{ 2 3 /* 4 5 如果我们在try或者catch语句块中抛出异常,finally语句是否会执行? 6 7 */ 8 public static void main(String[] args) { 9 try{ 10 Integer.parseInt 阅读全文
posted @ 2020-12-28 14:24 dog_IT 阅读(124) 评论(0) 推荐(0)
摘要:1 public class Demo13{ 2 3 4 /*Java规定: 5 1.必须捕获的异常,包括Exception及其子类,但不包括RuntimeException及其子类,这种类型的异常称为Checked Exception。 6 7 2.不需要捕获的异常,包括Error及其子类,Run 阅读全文
posted @ 2020-12-28 14:09 dog_IT 阅读(71) 评论(0) 推荐(0)
摘要:1 import java.util.*; 2 public class Demo13{ 3 4 5 /*Java规定: 6 1.必须捕获的异常,包括Exception及其子类,但不包括RuntimeException及其子类,这种类型的异常称为Checked Exception。 7 8 2.不需 阅读全文
posted @ 2020-12-27 17:03 dog_IT 阅读(57) 评论(0) 推荐(0)
摘要:1 import java.util.*; 2 public class Demo13{ 3 4 5 public static void main(String[] args) { 6 7 Weekday day = Weekday.SUN; 8 9 //将enum类型用于switch语句 10 阅读全文
posted @ 2020-12-27 11:44 dog_IT 阅读(561) 评论(0) 推荐(0)
摘要:1 public class ArrayExer3 { 2 public static void main(String[] args) { 3 //二分法查找前提:元素值是有序的 4 int[] arr = {-54,-36,-18,0,15,36,69,109,188,333}; 5 6 //查 阅读全文
posted @ 2020-12-27 00:39 dog_IT 阅读(212) 评论(0) 推荐(0)
摘要:1 import java.util.Arrays; 2 3 public class ArrayExer2 { 4 public static void main(String[] args) { 5 String[] arr = {"李苗","李大雪","鄢立文","李文娇","李娅芳"}; 6 阅读全文
posted @ 2020-12-26 23:56 dog_IT 阅读(144) 评论(0) 推荐(0)
摘要:1 import java.util.Arrays; 2 3 public class ArrayExer { 4 public static void main(String[] args) { 5 String[] arr = {"李苗","李大雪","鄢立文","李文娇","李娅芳"}; 6 阅读全文
posted @ 2020-12-26 23:37 dog_IT 阅读(111) 评论(0) 推荐(0)
摘要:1 import java.util.*; 2 public class Demo13{ 3 public static void main(String[] args) { 4 Weekday day = Weekday.SUN; 5 //int day = 1; 6 if(day.dayValu 阅读全文
posted @ 2020-12-26 21:58 dog_IT 阅读(110) 评论(0) 推荐(0)
摘要:`import java.util.Arrays; public class ArrayExer2 { public static void main(String[] args) { int[] arr = new int[10]; int sum = 0; for (int i = 0; i < 阅读全文
posted @ 2020-12-24 18:51 dog_IT 阅读(823) 评论(0) 推荐(0)
摘要:`import java.util.*; public class Demo13{ public static void main(String[] args) { int[] arr = new int[6]; outer:for(int i=0;i<arr.length;i++){ //先赋值一 阅读全文
posted @ 2020-12-24 17:15 dog_IT 阅读(106) 评论(0) 推荐(0)
摘要:` public class YanghuiTest3 { public static void main(String[] args) { //动态初始化一个10行的二维数组 int[][] yh = new int[10][]; for (int i = 0; i < yh.length; i+ 阅读全文
posted @ 2020-12-24 16:11 dog_IT 阅读(74) 评论(0) 推荐(0)
摘要:` public class YanghuiTest2 { public static void main(String[] args) { //动态初始化一个10行的二维数组 int[][] yh = new int[10][]; for (int i = 0; i < yh.length; i+ 阅读全文
posted @ 2020-12-24 15:50 dog_IT 阅读(94) 评论(0) 推荐(0)
摘要:` public class YanghuiTest { public static void main(String[] args) { int[][] yh = new int[10][]; for(int i=0;i<yh.length;i++){ yh[i] = new int[i+1]; 阅读全文
posted @ 2020-12-24 00:30 dog_IT 阅读(103) 评论(0) 推荐(0)
摘要:`import java.util.StringJoiner; public class Demo13{ public static void main(String[] args) { String[] names = {"Bob", "Alice", "Grace"}; //数组元素间用分隔符" 阅读全文
posted @ 2020-12-23 19:06 dog_IT 阅读(86) 评论(0) 推荐(0)
摘要:`import java.util.StringJoiner; public class Demo12{ public static void main(String[] args) { String[] names = {"Bob", "Alice", "Grace"}; //数组元素间用分隔符" 阅读全文
posted @ 2020-12-23 16:55 dog_IT 阅读(65) 评论(0) 推荐(0)
摘要:`public class Demo13 { public static void main(String[] args) { String[] fields = { "name", "position", "salary" }; String table = "employee"; String 阅读全文
posted @ 2020-12-23 14:31 dog_IT 阅读(95) 评论(0) 推荐(0)
摘要:`public class Demo12 { public static void main(String[] args) { String[] fields = { "name", "position", "salary" }; String table = "employee"; String 阅读全文
posted @ 2020-12-23 14:26 dog_IT 阅读(119) 评论(0) 推荐(0)
摘要:`import java.util.*; public class Demo11{ public static void main(String[] args){ String s1 = "hello"; String s2 = "hELLO".toLowerCase(); String s3 = 阅读全文
posted @ 2020-12-23 13:50 dog_IT 阅读(108) 评论(0) 推荐(0)
摘要:`//仿照StringBuilder,我们也可以设计支持链式操作的类。例如,一个可以不断增加的计数器 public class Demo12{ public static void main(String[] args) { Adder adder = new Adder(); adder.add( 阅读全文
posted @ 2020-12-22 21:55 dog_IT 阅读(87) 评论(0) 推荐(0)
摘要:` public class Demo12{ public static void main(String[] args) { //StringBuilder是可变字符串,可以预分配缓冲区,这样,往StringBuilder中新增字符时,不会创建新的临时对象:可以高效拼接字符串 StringBuil 阅读全文
posted @ 2020-12-22 20:57 dog_IT 阅读(70) 评论(0) 推荐(0)
摘要:`// 计算平均分 import java.util.Arrays; public class Demo12{ public static void main(String[] args) { // 用二维数组表示的学生成绩: int[][] scores = { { 82, 90, 91 }, { 阅读全文
posted @ 2020-12-22 17:06 dog_IT 阅读(684) 评论(0) 推荐(0)
摘要:`// 降序排序 import java.util.Arrays; public class Demo12{ public static void main(String[] args) { int[] ns = { 28, 12, 89, 73, 65, 18, 96, 50, 8, 36 }; 阅读全文
posted @ 2020-12-22 11:28 dog_IT 阅读(124) 评论(0) 推荐(0)
摘要:`import java.util.*; public class Demo13{ public static void main(String[] arg){ System.out.print("请输入学生数量:"); Scanner sc = new Scanner(System.in); in 阅读全文
posted @ 2020-12-22 11:15 dog_IT 阅读(233) 评论(0) 推荐(0)
摘要:`import java.util.*; public class Demo13{ public static void main(String[] arg){ int[] scores = {95,56,84,76,92}; int arrMax = 0; //遍历数组元素,将每个元素和arrMa 阅读全文
posted @ 2020-12-22 10:31 dog_IT 阅读(163) 评论(0) 推荐(0)
摘要:`import java.util.*; public class Demo13{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); System.out.println("请输入学生数量:"); 阅读全文
posted @ 2020-12-21 20:43 dog_IT 阅读(278) 评论(0) 推荐(0)
摘要:`import java.util.HashMap; public class Demo9{ public static void main(String[] args){ HashMap<Integer,String> m1 = new HashMap<>(); HashMap<Integer,S 阅读全文
posted @ 2020-12-14 17:20 dog_IT 阅读(650) 评论(0) 推荐(0)
摘要:一个数如果恰好等于它的因子之和,这个数就称为“完数”。例如1+2+3 = 6 编程:找出1000以内的所有完数(因子:除去这个数本身的其他约数) `public class Demo8{ public static void main(String[] args){ for(int i=1;i<=1 阅读全文
posted @ 2020-12-14 15:54 dog_IT 阅读(128) 评论(0) 推荐(0)
摘要:`public class Demo7{ public static void main(String[] args){ Outer outer = new Outer("wang"); outer.anonymHello(); } } class Outer{ public String name 阅读全文
posted @ 2020-12-13 16:18 dog_IT 阅读(498) 评论(0) 推荐(0)
摘要:`public class Demo{ public static void main(String[] args){ //记录质数个数 int count = 0; //获取当前时间 long start = System.currentTimeMillis(); //遍历100以内自然数 lab 阅读全文
posted @ 2020-12-13 14:53 dog_IT 阅读(254) 评论(0) 推荐(0)
摘要:`public class Demo3{ public static void main(String[] arg){ //获取当前时间距离1970-01-01 00:00:00的毫秒数 long start = System.currentTimeMillis(); //标识 i 是否被 j 除尽 阅读全文
posted @ 2020-12-06 16:18 dog_IT 阅读(243) 评论(0) 推荐(0)