随笔分类 -  基础+进阶

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页
摘要:注解_JDK内置注解 JDK中预定的一些注解: @Override:检测被该注解标注的方法是否是继承父类的 @Deprecated:该注解标注的内存,已过时 @SuppressWarnings:压制警告的 案例: public class Annotation1 { /** * JDK中预定的一些注 阅读全文
posted @ 2022-07-27 09:32 一位程序袁 阅读(92) 评论(0) 推荐(0)
摘要:自定义注解_格式和本质 我们这么创建自己的注解 案例: public @interface Sum {} 创建一个类然后加上@interface 就可以编程注解了 本质:注解本质上就是一个接口,该接口继承默认Annotation接口、 属性:接口中可以定义的成员方法 阅读全文
posted @ 2022-07-27 09:32 一位程序袁 阅读(29) 评论(0) 推荐(0)
摘要:反射获取字节码Class对象的三种方式 * *Field[] getFields() :获取所以public修饰的成员变量* Field getField( string name):获取指定public的成员变量* Field[] getDeclaredFields() :获取所以的成员变量* F 阅读全文
posted @ 2022-07-27 09:31 一位程序袁 阅读(40) 评论(0) 推荐(0)
摘要:反射_Class_获取Field 案例: public class Test3 { /** * * 3.获取成员方法们: * * *Method[] getMethods() :获取成员方法 * * Method getMethod( string name,类<?>... parameterTyp 阅读全文
posted @ 2022-07-26 14:18 一位程序袁 阅读(41) 评论(0) 推荐(0)
摘要:Junt使用步骤 测试分类: 黑盒测试:不需要写代码,给输入值,看程序是否能出期望的值 白盒测试:需要写代码,关注程序具体的执行流程 Junt使用:百盒子测试 步骤: 1.定义一个测试类(测试用例) 建议:测试类名:被测试的类名Test CalculatorTest 包名:xxx.xxx.xxx.x 阅读全文
posted @ 2022-07-26 10:37 一位程序袁 阅读(96) 评论(0) 推荐(0)
摘要:类的构造器使用 首先创建一个类Student public class Student { String name; public Student(String name) { this.name = name; } public Student() { } public String getNam 阅读全文
posted @ 2022-07-25 09:25 一位程序袁 阅读(58) 评论(0) 推荐(0)
摘要:方法的引用_通过super引用成员方法 案例: /** * 定义一个见面函数接口 */public interface Human {// 定义一个见面方法 void greet();} 在在定义一个父类 /** * 定义一个见面函数接口 */public interface Human {// 定 阅读全文
posted @ 2022-07-25 09:07 一位程序袁 阅读(43) 评论(0) 推荐(0)
摘要:方法引用的基本介绍 首先我们先来定义一个打印的接口 public class PrintableImpl { public static void PrintString(Printable printable){ printable.pring("HelloWorld"); } public st 阅读全文
posted @ 2022-07-25 08:41 一位程序袁 阅读(65) 评论(0) 推荐(0)
摘要:方法引用_通过类名引用静态的成员方法 定义一个抽象方法,传递一个整数,对整数进行绝对计算进行返回 案例: //定义一个函数式的接口public interface Printable { int sum(int number);} public class PrintableImpl { publi 阅读全文
posted @ 2022-07-24 21:37 一位程序袁 阅读(42) 评论(0) 推荐(0)
摘要:Stream流中常用的方法_limit limit可以对流进行截取,只截取前n个 参数是一个Long型,如果参数长度大于截取的长度 就进行截取,否者不进行操作 案例: public static void main(String[] args) { String[] arr={"aa","aaaa" 阅读全文
posted @ 2022-07-24 10:15 一位程序袁 阅读(338) 评论(0) 推荐(0)
摘要:流中的常用方法_concat 这个方法能把两个流合并成一个流 public static void main(String[] args) { Stream<String> aa = Stream.of("大傻", "张山", "ccc"); Stream<String> bb = Stream.o 阅读全文
posted @ 2022-07-24 10:14 一位程序袁 阅读(59) 评论(0) 推荐(0)
摘要:Stream流中的常用方法_map 如果需要将流中的元素映射到另一个流中,可以使用map方法 案例: public class map1 { public static void main(String[] args) { Stream<String> a = Stream.of("1", "2", 阅读全文
posted @ 2022-07-24 09:32 一位程序袁 阅读(272) 评论(0) 推荐(0)
摘要:Stream中的常用方法_filter filter方法的参数Peredicate是一个函数式接口,所以可以传递Lambda表达式,对数据进行过滤 Predicate中的抽象方法: boolean test(T t) 案例: public static void main(String[] args 阅读全文
posted @ 2022-07-24 09:21 一位程序袁 阅读(444) 评论(0) 推荐(0)
摘要:获取流的两种方式 获取流的非常简单,有一下这几种方式: 所有的Colleection集合都可以通过Stream默认方法获取流 Stream接口中的of可以获取数组对应的流 参数是一个可变参数,那么我们就可以传递一个数组 案例: public class Changyongfas { public s 阅读全文
posted @ 2022-07-24 09:11 一位程序袁 阅读(302) 评论(0) 推荐(0)
摘要:流的思想概述 图解: Stream(流)是一个来自数据源的元素队列·元素是特定类型的对象,形成一个队列。Java中的Stream并不会存储元素,而是按需计算。数据源流的来源。可以是集合,数组等。 阅读全文
posted @ 2022-07-23 17:16 一位程序袁 阅读(54) 评论(0) 推荐(0)
摘要:使用传统的方法遍历集合,对集合中的数据进行过滤 我们使用传统的方法和Stream流的方法来比较一下: public class List1 { public static void main(String[] args) { ArrayList<String> list = new ArrayLis 阅读全文
posted @ 2022-07-23 17:10 一位程序袁 阅读(49) 评论(0) 推荐(0)
摘要:常用函数式接口_andThen Function接口中的默认方法andThen:用来进行组合操作 需求: 把String类型的123转话为Integer类型,把转化后的结果加10 把增加之后Integar类型的数据,转化为String类型 分析:第一次是把string类型转换为了Integer类型所 阅读全文
posted @ 2022-07-23 16:39 一位程序袁 阅读(154) 评论(0) 推荐(0)
摘要:常用的函式接口_or&engate 案例: public class Han8 { /** * 定义一个方法String类型的字符串 * 传递一个Predicate接口,泛型使用String * 使用Predicate中test对字符串进行判断,并把判断结果返回 */ public static b 阅读全文
posted @ 2022-07-23 16:09 一位程序袁 阅读(55) 评论(0) 推荐(0)
摘要:常用函数式接口_Function接口 java.util.function.Function<T, R>接口用来根据一个类型的数据得到另一个类型的数据,前者称为前置条件,后者称为后置条件。Function接口中最主要的抽象方法为:R apply(T t),根据类型T的参数获取类型R的结果。使用的场景 阅读全文
posted @ 2022-07-23 16:09 一位程序袁 阅读(90) 评论(0) 推荐(0)
摘要:常用的函式接口 作用:接口中包含一个抽象方法: boolean test(T t):用来对指定数据类型数据进行判断方法 结果: 符合条件,返回true' 不符合条件的,返回false 案例: public class Han8 { /** * 定义一个方法String类型的字符串 * 传递一个Pre 阅读全文
posted @ 2022-07-23 14:48 一位程序袁 阅读(50) 评论(0) 推荐(0)

上一页 1 ··· 6 7 8 9 10 11 12 13 14 ··· 17 下一页