当前位置: 首页 > news >正文

Java8(JDK1.8)新特性

一、Java8(JDK1.8)新特性

1、Lamdba表达式

2、函数式接口

3、方法引用和构造引用

4、Stream API

5、接口中的默认方法和静态方法

6、新时间日期API

7、OPtional

8、其他特性

二、java8(JDK1.8)新特性简介

1、速度快;

2、代码少、简介(新增特性:lamdba表达式);

3、强大的Stream API;

4、使用并行流和串行流;

5、最大化较少空指针异常Optional;

其中最为核心的是Lambda表达式和Stream API

三、java8(JDK1.8)新特性详细介绍

一、Lambda表达式

1、Lambda表达式是什么?

Lambda是一个匿名函数,我们可以将Lambda表达式理解为一段可以传递的代码(将代码像数据一样传递)。使用它可以写出简洁、灵活的代码。作为一种更紧凑的代码风格,使java语言表达能力得到提升。

2、从匿名类到Lambda转换

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​public class Demo01 {    private static Logger log = LoggerFactory.getLogger(Demo01.class);​    public static void main(String[] args) {        Runnable t1 =new Runnable(){            @Override            public void run(){                log.info("我是没有使用Lambda表达式:不简洁");            }        };                Runnable t2 = () -> log.info("我是使用Lambda表达式:简洁、灵活");                t1.run();        t2.run();            }}​

Run result

19:43:39.303 [main] INFO com.chen.test.JAVA8Features.Demo01 - 我是没有使用Lambda表达式:不简洁、代码多19:43:39.303 [main] INFO com.chen.test.JAVA8Features.Demo01 - 我是使用Lambda表达式:简洁、灵活​Process finished with exit code 0​

3、Lambda表达式语法

Lambda表达式在java语言中引入了一种新的语法元素和操作。这种操作符号为“->”,Lambda操作符或箭头操作符,它将Lambda表达式分割为两部分。 左边:指Lambda表达式的所有参数 右边:指Lambda体,即表示Lambda表达式需要执行的功能。

六种语法格式:

1、语法格式一:无参数、无返回值,只需要一个Lambda体

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​public class Demo02 {    private static Logger log = LoggerFactory.getLogger(Demo02.class);​    public static void main(String[] args) {        Runnable t1 = ()-> log.info("Lambda表达式:简洁、灵活,优雅永不过时");        t1.run();    }}

run result

22:22:39.125 [main] INFO com.chen.test.JAVA8Features.Demo02 - Lambda表达式:简洁、灵活,优雅永不过时​Process finished with exit code 0

2、语法格式二:lambda有一个参数、无返回值

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.function.Consumer;​public class Demo03 {    private static Logger log = LoggerFactory.getLogger(Demo03.class);    public static void main(String[] args) {        Consumer<String> consumer = new Consumer<String>() {            @Override            public void accept(String s) {                log.info(s);            }        };        consumer.accept("爱与被爱的区别");​        Consumer<String> consumer1 = (s) -> log.info(s);        consumer1.accept("接受爱不一定爱对方,爱一定付出真心爱");    }}​

run result

23:03:08.992 [main] INFO com.chen.test.JAVA8Features.Demo03 - 爱与被爱的区别23:03:09.142 [main] INFO com.chen.test.JAVA8Features.Demo03 - 接受爱不一定爱对方,爱一定付出真心爱​Process finished with exit code 0

3、语法格式三:Lambda只有一个参数时,可以省略()

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.function.Consumer;​public class Demo04 {    private static Logger log = LoggerFactory.getLogger(Demo04.class);    public static void main(String[] args) {        Consumer<String> consumer = s -> log.info(s);        consumer.accept("Lambda只有一个参数时,可以省略()");    }}

run result

23:08:27.295 [main] INFO com.chen.test.JAVA8Features.Demo04 - Lambda只有一个参数时,可以省略()​Process finished with exit code 0

4、语法格式四:Lambda有两个参数时,并且有返回值

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.Comparator;​​public class Demo05 {    private static Logger log = LoggerFactory.getLogger(Demo05.class);​    public static void main(String[] args) {        CompareOldMethod(12,10);        findMaxValue(12,10);        findMinValue(12,10);    }//    没有使用Lambda表达式比较大小    public static void CompareOldMethod(int num1,int num2){        Comparator<Integer> comparator = new Comparator<Integer>() {            @Override            public int compare(Integer o1, Integer o2) {                log.info("o1:{}",o1);                log.info("o2:{}",o2);                return o1 < o2 ? o2 : o1;            }        };        log.info("OldFindMaxValue:{}",comparator.compare(num1,num2));    }​//    使用lambda表达式    public static void findMaxValue(int num1,int num2){        Comparator<Integer> comparatorMax = (o1, o2) ->{​            log.info("o1:{}",o1);            log.info("o2:{}",o2);            return (o1<o2)? o2 :(o1);        };​        log.info("findMaxValue:{}",(comparatorMax.compare(num1,num2)));​    }    public static void findMinValue(int num1,int num2){        Comparator<Integer> comparatorMin =  (o1, o2) -> {            log.info("o1:{}",o1);            log.info("o2:{}",o2);            return (o1 < o2) ? o1 : o2;        };        log.info("FindMinValue:{}",comparatorMin.compare(num1,num2));    }}​

run result

00:17:10.206 [main] INFO com.chen.test.JAVA8Features.Demo05 - o1:1200:17:10.206 [main] INFO com.chen.test.JAVA8Features.Demo05 - o2:1000:17:10.206 [main] INFO com.chen.test.JAVA8Features.Demo05 - OldFindMaxValue:1200:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - o1:1200:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - o2:1000:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - findMaxValue:1200:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - o1:1200:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - o2:1000:17:10.315 [main] INFO com.chen.test.JAVA8Features.Demo05 - FindMinValue:10​Process finished with exit code 0​

5、语法格式五:当Lambda体只有一条语句的时候,return和{}可以省略掉

package com.chen.test.JAVA8Features;​import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.Comparator;​​public class Demo05 {    private static Logger log = LoggerFactory.getLogger(Demo05.class);​    public static void main(String[] args) {        findMaxValue(12,10);        findMinValue(12,10);    }​//    使用lambda表达式    public static void findMaxValue(int num1,int num2){        Comparator<Integer> comparatorMax = (o1, o2) ->{​            log.info("o1:{}",o1);            log.info("o2:{}",o2);            return (o1<o2)? o2 :(o1);        };​        log.info("findMaxValue:{}",(comparatorMax.compare(num1,num2)));​    }    public static void findMinValue(int num1,int num2){        Comparator<Integer> comparatorMin =  (o1, o2) -> (o1 < o2) ? o1 : o2;​        log.info("FindMinValue:{}",comparatorMin.compare(num1,num2));    }}​

run result

00:22:31.059 [main] INFO com.chen.test.JAVA8Features.Demo05 - o1:1200:22:31.075 [main] INFO com.chen.test.JAVA8Features.Demo05 - o2:1000:22:31.075 [main] INFO com.chen.test.JAVA8Features.Demo05 - findMaxValue:1200:22:31.075 [main] INFO com.chen.test.JAVA8Features.Demo05 - FindMinValue:10​Process finished with exit code 0

6、语法格式六:类型推断:数据类型可以省略,因为编译器可以推断得出,成为“类型推断”

package com.chen.test.JAVA8Features;​import com.mysql.cj.callback.MysqlCallbackHandler;import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.ArrayList;import java.util.Comparator;import java.util.List;import java.util.function.Consumer;​​public class Demo07 {    private static Logger log = LoggerFactory.getLogger(Demo07.class);​    public static void main(String[] args) {        dateType();    }​    public static void dateType(){        Consumer<String> consumer = (String s) -> log.info(s);        consumer.accept("Hello World !");​        Consumer<String> consumer1 = (s) -> log.info(s);        consumer1.accept("Hello don't date type !");    }}

二、函数式接口

1、什么是函数式接口?

函数式接口:只包含一个抽象方法的接口,称为函数式接口,并且可以使用lambda表达式来创建该接口的对象,可以在任意函数式接口上使用@FunctionalInterface注解,来检测它是否是符合函数式接口。同时javac也会包含一条声明,说明这个接口是否符合函数式接口。

2、自定义函数式接口

package com.chen.test.JAVA8Features;​@FunctionalInterfacepublic interface FunctionDemo1 {    public void fun();}

3、泛型函数式接口

package com.chen.test.JAVA8Features;​@FunctionalInterfacepublic interface FunctionGeneric<T> {    public void fun(T t);​}

4、java内置函数式接口

(Function、Consumer、Supplier、Predicate) java.util.function

Function (函数型接口)

函数型接口:有输入参数,也有返回值。

 * @param <T> the type of the input to the function * @param <R> the type of the result of the function * * @since 1.8 */@FunctionalInterfacepublic interface Function<T, R> {​    /**     * Applies this function to the given argument.     *     * @param t the function argument     * @return the function result     */    R apply(T t);

其中T表示输入参数,R为返回值

代码展示:

    public void functionTest(){//        Function function = new Function<String,String>(){//            @Override//            public String apply(String s) {//                return s;//            }//        };//        log.info("函数型接口 :{}",function.apply("没有使用Lambda表达式"));​        Function function = s -> s;        log.info("函数型接口:{}",function.apply("Function Demo"));    }

Consumer(消费型接口)

消费型接口:有入参,没有会有返回值

* @param <T> the type of the input to the operation * * @since 1.8 */@FunctionalInterfacepublic interface Consumer<T> {​    /**     * Performs this operation on the given argument.     *     * @param t the input argument     */    void accept(T t);

代码展示:

 public void consumerTest(){//        非Lambda表达式//        Consumer<String> consumer = new Consumer<String>() {//            @Override//            public void accept(String s) {//                log.info(s);//            }//        };//        consumer.accept("消费型函数:没有使用Lambda表达式");​//        使用Lambda表达式        Consumer<String> consumer = s -> log.info(s);        consumer.accept("消费型函数:Consumer Demo");​    }

Supplier(供给型接口)

供给型接口:没有输入参数,有返回值

 * * @param <T> the type of results supplied by this supplier * * @since 1.8 */@FunctionalInterfacepublic interface Supplier<T> {​    /**     * Gets a result.     *     * @return a result     */    T get();}

代码展示:

  public void supplierTest(){//        非Lambda表达式//        Supplier supplier = new Supplier<String>(){//            @Override//            public String get() {//                return "供给型接口:没有使用Lambda表达式";//            }//        };//        log.info(String.valueOf(supplier.get()));​        Supplier supplier =  () -> "供给型接口:Supplier Demo";        log.info(String.valueOf(supplier.get()));    }

Predicate(断定型接口)

断言型接口:既有输入参数也有返回值,返回类型是boolean类型

* @param <T> the type of the input to the predicate * * @since 1.8 */@FunctionalInterfacepublic interface Predicate<T> {​    /**     * Evaluates this predicate on the given argument.     *     * @param t the input argument     * @return {@code true} if the input argument matches the predicate,     * otherwise {@code false}     */    boolean test(T t);

展示代码:

public void predicateTest() {//        Predicate<String> predicate = new Predicate<String>() {//            @Override//            public boolean test(String s) {//                return s.equals("Predicate Demo");//            }//        };//        log.info("断言型接口:{}",predicate.test("没有使用Lambda表达式"));        Predicate<String> predicate = s -> s.equals("Predicate Demo");        log.info("断言型接口:{}",predicate.test("Predicate Demo"));    }

java内置四种大函数式接口,可以使用Lambda表达式

package com.chen.test.JAVA8Features;​import com.google.common.base.Function;import org.slf4j.Logger;import org.slf4j.LoggerFactory;​import java.util.function.Consumer;import java.util.function.Predicate;import java.util.function.Supplier;​public class FunDemo01 {    private static Logger log = LoggerFactory.getLogger(FunDemo01.class);    public static void main(String[] args) {        FunDemo01 demo01 = new FunDemo01();        demo01.functionTest();        demo01.consumerTest();        demo01.supplierTest();        demo01.predicateTest();​    }    public void functionTest(){//        非Lambda表达式//        Function function = new Function<String,String>(){//            @Override//            public String apply(String s) {//                return s;//            }//        };//        log.info("函数型接口 :{}",function.apply("没有使用Lambda表达式"));​        Function function = s -> s;        log.info("函数型接口:{}",function.apply("Function Demo"));    }​    public void consumerTest(){//        非Lambda表达式//        Consumer<String> consumer = new Consumer<String>() {//            @Override//            public void accept(String s) {//                log.info(s);//            }//        };//        consumer.accept("消费型函数:没有使用Lambda表达式");​//        使用Lambda表达式        Consumer<String> consumer = s -> log.info(s);        consumer.accept("消费型函数:Consumer Demo");​    }    public void supplierTest(){//        非Lambda表达式//        Supplier supplier = new Supplier<String>(){//            @Override//            public String get() {//                return "供给型接口:没有使用Lambda表达式";//            }//        };//        log.info(String.valueOf(supplier.get()));​        Supplier supplier =  () -> "供给型接口:Supplier Demo";        log.info(String.valueOf(supplier.get()));    }    public void predicateTest() {//        Predicate<String> predicate = new Predicate<String>() {//            @Override//            public boolean test(String s) {//                return s.equals("Predicate Demo");//            }//        };//        log.info("断言型接口:{}",predicate.test("没有使用Lambda表达式"));        Predicate<String> predicate = s -> s.equals("Predicate Demo");        log.info("断言型接口:{}",predicate.test("Predicate Demo"));    }​}

三、方法引用和构造器引用

1、方法引用

当要传递给Lambda体的操作已经有实现方法,可以直接使用方法引用(实现抽象方法的列表,必须要和方法引用的方法参数列表一致)

方法引用:使用操作符“::”将方法名和(类或者对象)分割开来。

有下列三种情况:

  1. 对象::实例方法

  2. 类::实例方法

  3. 类::静态方法

代码展示:

package com.chen.test.JAVA8Features;​public class MethodRefDemo {    public static void main(String[] args) {        FunctionGeneric<String> strName = s -> System.out.println(s);        strName.fun("Lambda表达式没有使用方法引用");                //方法引用        FunctionGeneric<String> strName2 = System.out::println;        strName2.fun("使用方法引用");​​    }}​

2、构造器引用

本质上:构造器引用和方法引用相识,只是使用了一个new方法

使用说明:函数式接口参数列表和构造器参数列表要一致,该接口返回值类型也是构造器返回值类型

格式:ClassName :: new

代码展示:

package com.chen.test.JAVA8Features;​import java.util.function.Function;​public class MethodRefDemo {    public static void main(String[] args) {​        //构造器引用        Function<String, Integer> fun1 = (num) -> new Integer(num);        Function<String, Integer> fun2 = Integer::new;​        //数组引用        Function<Integer,Integer[]> fun3 = (num) ->new Integer[num];        Function<Integer,Integer[]> fun4 = Integer[]::new;    }}​

四、强大的Stream API

1、什么是Stream?

Java8中两个最为重要特性:第一个的是Lambda表达式,另一个是Stream API。

StreamAPI它位于java.util.stream包中,StreamAPI帮助我们更好地对数据进行集合操作,它本质就是对数据的操作进行流水线式处理,也可以理解为一个更加高级的迭代器,主要作用是遍历其中每一个元素。简而言之,StreamAP提供了一种高效且易于使用的处理数据方式。

2、Stream特点:

  • 1、Stream自己不会存储数据。

  • 2、Stream不会改变源对象。相反,它们会返回一个持有结果的新Stream对象

  • 3、Stream操作时延迟执行的。这就意味着它们等到有结果时候才会执行。

  • 和list不同,Stream代表的是任意Java对象的序列,且stream输出的元素可能并没有预先存储在内存中,而是实时计算出来的。它可以“存储”有限个或无限个元素。

    例如:我们想表示一个全体自然数的集合,使用list是不可能写出来的,因为自然数是无线的,不管内存多大也没法放到list中,但是使用Sream就可以

3、Stream操作的三个步骤?

  • 1、创建Stream:一个数据源(例如:set 、list),获取一个流

  • 2、中间操作:一个中间操作连接,对数据源的数据进行处理

  • 3、终止操作:一个终止操作,执行中间操作连,产生结果。

1、创建流

创建流方式有多种:

第一种:通过集合

对于Collection接口(List 、Set、Queue等)直接调用Stream()方法可以获取Stream

        List<String> list = new ArrayList<>();        Stream<String> stringStream = list.stream(); //返回一个顺序流        Stream<String> parallelStream = list.parallelStream(); //返回一个并行流(可多线程)

第二种:通过数组

把数组变成Stream使用Arrays.stream()方法

        Stream<String> stream1 = Arrays.stream(new String[]{"CBB", "YJJ", "CB", "CJJ"});​

第三种:Stream.of()静态方法直接手动生成一个Stream

        Stream<String> stream = Stream.of("A", "B", "C", "D");

第四种:创建无限流

        //迭代        //遍历10个奇数        Stream.iterate(1,t->t+2).limit(10).forEach(System.out::println);​        //生成        //生成10个随机数        Stream.generate(Math::random).limit(10).forEach(System.out::println);​

第五种:自己构建

第六种:其他等等

2、中间操作

一个流可以后面跟随着0个或者多个中间操作,其目的是打开流,做出某种程度的数据过滤、去重、排序、映射、跳过等。然后返回一个新的流,交给下一个使用,仅仅是调用这个方法,没有真正开始遍历。

map (mapToInt, flatMap 等)、 filter、 distinct、 sorted、 peek、 limit、 skip、 parallel、 sequential、 unordered

3、终止操作:一个终止操作,执行中间操作连,产生结果。

forEach、 forEachOrdered、 toArray、 reduce、 collect、 min、 max、 count、 anyMatch、 allMatch、 noneMatch、 findFirst、 findAny、 iterator

package com.chen.test.JAVA8Features.Stream;​import java.util.*;import java.util.stream.Collectors;​public class StreamDemo01 {    public static void main(String[] args) {​        List<Integer> list = new ArrayList<>();        for (int i = 0; i < 10; i++) {            list.add(i);        }        //map        List<Integer> collect = list.stream().map(n -> n * 2).collect(Collectors.toCollection(ArrayList::new));        collect.forEach(System.out::println);        //filer 过滤        List<Integer> list1 = list.stream().filter(n -> n % 2 == 0).collect(Collectors.toList());        list1.forEach(System.out::println);        //distinct 去重        List<Integer> list2 = list.stream().distinct().collect(Collectors.toList());        list2.forEach(System.out::println);        //skip 跳过        List<Integer> list3 = list.stream().skip(3).collect(Collectors.toList());        list3.forEach(System.out::println);        //limit 截取        Set<Integer> set = list.stream().limit(3).collect(Collectors.toSet());        set.forEach(System.out::println);        //skip  and limit 组合使用        List<Integer> list4 = list.stream().skip(3).limit(5).collect(Collectors.toList());        list4.forEach(System.out::println);​    }}​

五、接口中默认方法和静态方法

1、默认方法

java8允许接口中包含具体实现的方法体,该方法是默认方法,它需要使用default关键字修饰

2、静态方法

java8中允许接口中定义静态方法,使用static关键字修饰

代码展示:

package com.chen.test.JAVA8Features.DefaultMethod;​public interface DefaultMethodDemo {        default Integer addMethod(int a ,int b){        System.out.println("我是默认方法");        return a+b;    }    static void test(){        System.out.println("我是静态方法");    }}​

六、新时间日期接口

七、Optional类

optional类是一个容器,代表一个值存在或者不存在,原来使用null表示一个值存不存在,现在使用optional可以更好的表达这个概念,并且可以避免空指针异常。

Optional常用的方法:

  1. Optional.of(T t) : 创建一个Optional实例;

  2. Optional.empty() : 创建一个空的Optional实例;

  3. Optional.ofNullable(T t) :若t不为空创建一个Optional实例否则创建一个空实例;

  4. isPresent() : 判断是否包含值;

  5. orElse(T t) :如果调用对象包含值,返回该值,否则返回t;

  6. orElseGet(Supplier s) : 如果调用对象包含值,返回该值,否则返回s获取的值;

  7. map(Function f) : 如果有值对其处理,并返回处理后的Optional,否则返回Optional.empty();

  8. flatMap(Function mapper) : 与map类似,要求返回值必须是Optional。

相关文章:

Java8(JDK1.8)新特性

一、Java8(JDK1.8)新特性 1、Lamdba表达式 2、函数式接口 3、方法引用和构造引用 4、Stream API 5、接口中的默认方法和静态方法 6、新时间日期API 7、OPtional 8、其他特性 二、java8&#xff08;JDK1.8&#xff09;新特性简介 1、速度快&#xff1b; 2、代码少、简…...

【C语言】指针的定义和使用

指针一、什么是指针二、指针类型三、指针和数组的关系四、空指针五、野指针一、什么是指针 指针&#xff08;Pointer&#xff09;是编程语言中的一个对象&#xff0c;通过地址直接指向内存中该地址的值。由于通过地址能够找到所需的变量存储单元&#xff0c;可以说地址指向该变…...

Parameter ‘zpspid‘ not found

异常&#xff1a;nested exception is org.apache.ibatis.binding.BindingException: Parameter testypid not found. Available parameters are [ztpsXmjcxx, pageable, param1, param2]分析&#xff1a;以为是xml文件中没有对应的字段&#xff0c;一细看了几遍是有这个字段的…...

23、高自由度下的E类波形理论计算(附Matlab代码)

23、高自由度下的E类波形理论计算&#xff08;附Matlab代码&#xff09; 0、代码 任意占空比、电压导数条件下的E类波形与阻抗条件计算Matlab 注意修改路径&#xff0c;我这边是&#xff1a;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#xff01;&#…...

软件测试:用“bug”来表示“在电脑程序里的错误”

计算机基础知识计算机&#xff08;personal computer&#xff09;俗称电脑&#xff08;pc&#xff09;&#xff0c;是现代一种用于高速计算的电子机器&#xff0c;可以进行数值计算&#xff0c;又可以进行逻辑判断&#xff0c;还具有存储记忆功能&#xff0c;且能够按照程序的运…...

Git命令

git init # 初始化本地git仓库&#xff08;创建新仓库&#xff09;git config --global user.name "xxx" # 配置用户名git config --global user.email "xxxxxx.com" # 配置邮件git config --global color.ui true # git status等命令自动着色git config -…...

Java的异常概念和类型

Java是一种流行的编程语言&#xff0c;拥有强大的异常处理机制&#xff0c;以帮助开发人员在程序出现异常时更好地处理错误情况。本文将介绍Java异常的概念和类型。异常的概念在Java中&#xff0c;异常是指在程序运行时发生的错误或异常情况。例如&#xff0c;当程序试图打开不…...

【Leedcode】环形链表必备的面试题和证明题(附图解)

环形链表必备的面试题和证明题&#xff08;附图解&#xff09; 文章目录环形链表必备的面试题和证明题&#xff08;附图解&#xff09;前言一、第一题1.题目2.思路3.代码4.延伸问题(1)证明题一&#xff1a;(2)证明题二&#xff1a;二、第二题1.题目2.思路延伸的证明题总结前言 …...

Vulnhub靶场----7、DC-7

文章目录一、环境搭建二、渗透流程三、思路总结一、环境搭建 DC-7下载地址&#xff1a;https://download.vulnhub.com/dc/DC-7.zip kali&#xff1a;192.168.144.148 DC-7&#xff1a;192.168.144.155 二、渗透流程 nmap -T5 -A -p- -sV -sT 192.168.144.155思路&#xff1a; …...

【Unity VR开发】结合VRTK4.0:创建滑块

语录&#xff1a; 只有经历地狱般的磨练&#xff0c;才能炼出创造天堂的力量。 前言&#xff1a; 滑块是一个非常简单的控件&#xff0c;它允许通过沿有限的驱动轴滑动 Interactable 来选择不同的值。我们将使用线性驱动器创建一个滑块控件&#xff0c;该控件允许我们根据与滑…...

Latex中的表格(2)

Latex中的表格一、一个加脚注的三线表的例子二、表格中加注释三、并排的表格3.1 使用小页环境并排表格3.2 使用子表格并排表格四、一个复杂的表格五、一个长表格这篇文章主要罗列一些特殊的表格例子。内容来自&#xff1a;一篇北师大学位论文模板&#xff0c;详见https://githu…...

(七)输运定理

本文主要内容包括&#xff1a;1. 物质积分2. 曲线上物质积分的时间变化率3. 曲面上物质积分的时间变化率4. 体积域上物质积分的时间变化率 (Reynolds 输运定理)1. 物质积分 考虑 t0t_0t0​ 时刻参考构型中由物质点 X⃗\vec{X}X所形成的 物质曲线 ct0c_{t_0}ct0​​、物质曲面 …...

ABBYYFineReader15免费电脑pdf文档文字识别软件

ABBYYFineReader是一款OCR文字识别软件&#xff0c;它可以对图片、文档等进行扫描识别&#xff0c;并将其转换为可编辑的格式&#xff0c;比如Word、Excel等&#xff0c;操作也是挺方便的。 我们在官网找到该软件并进行下载&#xff0c;打开软件后&#xff0c;选择转换为“Mic…...

顺序表(超详解哦)

全文目录引言顺序表定义静态顺序表动态顺序表动态顺序表的接口实现顺序表的初始化与销毁顺序表尾插/尾删顺序表头插/头删顺序表在pos位置插入/删除顺序表的打印顺序表中的查找总结引言 在生产中&#xff0c;为了方便管理数据&#xff0c;我们经常会需要将一些数据连续的存储起…...

Compose-Animation高级别动画

目录前言AnimatedVisibilityisScrollingUpFABscaffoldanimateContentSizeCrossfade顶部气泡下弹前言 AnimatedVisibility 驱动可视性相关动画&#xff0c;即布局显隐 animateContentSize 内容变换动画相关 Crossfade 布局&#xff08;或者页面&#xff09;切换过渡动画 Animat…...

c++11 标准模板(STL)(std::unordered_set)(八)

定义于头文件 <unordered_set> template< class Key, class Hash std::hash<Key>, class KeyEqual std::equal_to<Key>, class Allocator std::allocator<Key> > class unordered_set;(1)(C11 起)namespace pmr { templ…...

Python每日一练(20230225)

目录 1. 整数反转 2. 求最大公约数和最小公倍数 最大公约数 最小公倍数 3. 单词搜索 II 附录&#xff1a; DFS 深度优先搜索算法 BFS 广度优先搜索算法 BFS 和 DFS 的区别 1. 整数反转 给你一个 32 位的有符号整数 x &#xff0c;返回将 x 中的数字部分反转后的结果。…...

基于博客系统的测试用例

登陆界面博客预览页博客详情页博客编辑页...

C语言运算符算术运算符关系运算符

C 运算符 运算符是一种告诉编译器执行特定的数学或逻辑操作的符号。C 语言内置了丰富的运算符&#xff0c;并提供了以下类型的运算符&#xff1a; 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 杂项运算符 本章将逐一介绍算术运算符、关系运算符、逻辑运算符、位运…...

C语言 深度剖析数据在内存中的存储

目录数据类型详细介绍整形在内存中的存储&#xff1a;原码&#xff0c;反码&#xff0c;补码大小端字节序介绍及判断浮点型在内存中的存储解析数据类型详细介绍整形&#xff1a;1.为什么char类型也会归类到整形家族当中去呢&#xff1f;字符存储和表示的时候本质上使用的是ASCI…...

MyBatis快速开发

查询user表中的所有数据 步骤&#xff1a; 创建user表 打开Navicat&#xff0c;新建查询&#xff0c;将下面SQL代码复制粘贴并执行&#xff1a; create database mybatis; use mybatis;drop table if exists tb_user;create table tb_user(id int primary key auto_incremen…...

大数据常见应用场景及架构改进

大数据常见应用场景及架构改进大数据典型的离线处理场景1.大数据数据仓库及它的架构改进2.海量数据规模下的搜索与检索3.新兴的图计算领域4.海量数据挖掘潜在价值大数据实时处理场景大数据典型的离线处理场景 1.大数据数据仓库及它的架构改进 对于离线场景&#xff0c;最典型…...

【华为OD机试模拟题】用 C++ 实现 - 挑选字符串(2023.Q1)

最近更新的博客 【华为OD机试模拟题】用 C++ 实现 - 货币单位换算(2023.Q1) 【华为OD机试模拟题】用 C++ 实现 - 选座位(2023.Q1) 【华为OD机试模拟题】用 C++ 实现 - 停车场最大距离(2023.Q1) 【华为OD机试模拟题】用 C++ 实现 - 重组字符串(2023.Q1) 【华为OD机试模…...

程序员是世界上最理性、最睿智的群体,耶稣也反驳不了我,我说的!

有人说&#xff0c;程序员是吃青春饭的&#xff0c;35 岁就提前退休了。 猛一看&#xff0c;这句话是对的&#xff1b;仔细一看&#xff0c;这句话是不对的。 说它对&#xff0c;是因为现实中确实有很多程序员 35 岁就被毕业了&#xff1b;说它不对&#xff0c;是因为 35 岁以…...

人工智能到底是什么?

人工智能&#xff08;Artificial Intelligence&#xff0c;AI&#xff09;是一种利用计算机科学和统计学理论和技术来实现人类智能的一门交叉学科&#xff0c;旨在使计算机系统能够模拟、扩展和增强人类的智能能力&#xff0c;使计算机能够像人类一样思考、学习、决策和执行任务…...

在动态规划的海洋中遨游(三)

前言&#xff1a;\textcolor{Green}{前言&#xff1a;}前言&#xff1a; &#x1f49e; 好久没写题&#xff0c;有点生疏了。这也是给大家提一个醒&#xff0c;一定要一直坚持下去&#xff0c;哪怕每天只做一点点。&#x1f49e; 算法类别一、算法介绍原理适用的情况做题步骤二…...

enable_if模板编程实现字节序转换模板

enable_if和SFINAESFINAE是模板的一个特性&#xff0c;也就是替换失败不报错。正常来说&#xff0c;函数匹配的时候按照优先级依次匹配定义的重载函数&#xff0c;最终选择最佳匹配的函数运行。模板也是一样的&#xff0c;但是在替换模板时&#xff0c;即使出现异常错误也不认为…...

【人工智能与深度学习】基于能量的模型

【人工智能与深度学习】基于能量的模型 概述能量基础模型(EBM)方法定义解决方案:基于梯度的推理有潜在变量的能量基础模型推理例子能量基础模型和机率模型的对比自由能(Free Energy)概述 我们现在介绍一个新框架来定义模型。它提供了一个统一和系列性的方式来定义「监督模型」…...

功能测试三年,是应该改变了

前言 测试行业3年多经验&#xff0c;学历大专自考本科&#xff0c;主要测试方向web&#xff0c;PC端&#xff0c;wap站&#xff0c;小程序公众号都测试过&#xff0c;app也测过一些&#xff0c;C端B端都有&#xff0c;除功能外&#xff0c;接口性能也有涉猎&#xff0c;但是不…...

基于STM32的ubuntu交叉编译环境的搭建(arm-gcc 8.2)

常用的STM32的软件开发方法都是基于MDK keil或IAR集成开发环境&#xff0c;但以上两个集成开发环境软件都是需要收费的&#xff0c;且价格较为昂贵。本节介绍一种在ubuntu上安装arm gcc&#xff08;arm-eabi&#xff09;的方式&#xff0c;用于编译STM32的程序。 1.在arm官网下…...