06 2020 档案
摘要:在类的声明中,可以包含多个初始化块,当创建类的实例时,就会依次执行这些代码块。如果使用 static 修饰初始化块,就称为静态初始化块。 需要特别注意:静态初始化块只在类加载时执行,且只会执行一次,同时静态初始化块只能给静态变量赋值,不能初始化普通的成员变量。 package com.komiles
阅读全文
摘要:1. 使用 stream 将一个数组放进 stream 里面,然后直接调用 stream 里的 min 或 max 函数得到最大值。 @Test public void index2(){ int ages[] = {18 ,23 ,21 ,19 ,25 ,29 ,17}; int maxNum =
阅读全文
摘要:java中对数组进行排序 使用Array.sort() 这个默认是升序 @Test public void index4(){ int scores[] = new int[]{1,2,3,89,4}; Arrays.sort(scores); for (int i:scores ) { Syste
阅读全文