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

基础复习第二十二天 泛型的使用

泛型

JDK1.5设计了泛型的概念。泛型即为“类型参数”,这个类型参数在声明它的类、接口或方法中,代表未知的通用的类型。例如:

java.lang.Comparable接口和java.util.Comparator接口,是用于对象比较大小的规范接口,这两个接口只是限定了当一个对象大于另一个对象时返回正整数,小于返回负整数,等于返回0。但是并不确定是什么类型的对象比较大小,之前的时候只能用Object类型表示,使用时既麻烦又不安全,因此JDK1.5就给它们增加了泛型。

public interface Comparable<T>{int compareTo(T o) ;
}
public interface Comparator<T>{int compare(T o1, T o2) ;
}

其中<T>就是类型参数,即泛型。

泛型的好处

那么我们在使用如上面这样的接口时,如果没有泛型或不指定泛型,很麻烦,而且有安全隐患。如果有了泛型并使用泛型,那么既能保证安全,又能简化代码。

JavaBean:圆类型

class Circle{private double radius;public Circle(double radius) {super();this.radius = radius;}public double getRadius() {return radius;}public void setRadius(double radius) {this.radius = radius;}@Overridepublic String toString() {return "Circle [radius=" + radius + "]";}}

比较器

import java.util.Comparator;public class CircleComparator implements Comparator{@Overridepublic int compare(Object o1, Object o2) {//强制类型转换Circle c1 = (Circle) o1;Circle c2 = (Circle) o2;return Double.compare(c1.getRadius(), c2.getRadius());}}

测试类

public class TestGeneric {public static void main(String[] args) {CircleComparator com = new CircleComparator();System.out.println(com.compare(new Circle(1), new Circle(2)));System.out.println(com.compare("圆1", "圆2"));//运行时异常:ClassCastException}
}

使用泛型:

比较器:

class CircleComparator implements Comparator<Circle>{@Overridepublic int compare(Circle o1, Circle o2) {//不再需要强制类型转换,代码更简洁return Double.compare(o1.getRadius(), o2.getRadius());}}

测试类

import java.util.Comparator;public class TestGeneric {public static void main(String[] args) {CircleComparator com = new CircleComparator();System.out.println(com.compare(new Circle(1), new Circle(2)));//        System.out.println(com.compare("圆1", "圆2"));//编译错误,因为"圆1", "圆2"不是Circle类型,编译器提前报错,而不是冒着风险在运行时再报错}
}

其中:<T>是类型变量(Type Variables),Comparator<T>这种就称为参数化类型(Parameterized Types),Comparator<Circle>中的<Circle>是参数化类型的类型参数<Type Arguments of Parameterized Types>。

类比方法的参数,我们可以把<T>,称为类型形参,将<Circle>称为类型实参,有助于我们理解泛型。 

参数类型:泛型类与泛型接口

当我们在声明类或接口时,类或接口中定义某个成员时,该成员有些类型是不确定的,而这个类型需要在使用这个类或接口时才可以确定,那么我们可以使用泛型。

声明泛型类与泛型接口

语法格式:

【修饰符】 class 类名<类型变量列表>{}
【修饰符】 interface 接口名<类型变量列表>{}
<类型变量列表>:可以是一个或多个类型变量,一般都是使用单个的大写字母表示。例如:<T>、<K,V>等。
<类型变量列表>中的类型变量不能用于静态成员上。

示例代码:

例如:我们要声明一个学生类,该学生包含姓名、成绩,而此时学生的成绩类型不确定,为什么呢,因为,语文老师希望成绩是“优秀”、“良好”、“及格”、“不及格”,数学老师希望成绩是89.5, 65.0,英语老师希望成绩是'A','B','C','D','E'。那么我们在设计这个学生类时,就可以使用泛型。

public class Student<T>{private String name;private T score;public Student() {super();}public Student(String name, T score) {super();this.name = name;this.score = score;}public String getName() {return name;}public void setName(String name) {this.name = name;}public T getScore() {return score;}public void setScore(T score) {this.score = score;}@Overridepublic String toString() {return "姓名:" + name + ", 成绩:" + score;}
}
使用泛型类与泛型接口

在使用这种参数化的类与接口时,我们需要指定泛型变量的实际类型参数:

(1)实际类型参数必须是引用数据类型,不能是基本数据类型

(2)在创建类的对象时指定类型变量对应的实际类型参数

public class TestGeneric{public static void main(String[] args) {//语文老师使用时:Student<String> stu1 = new Student<String>("张三", "良好");//数学老师使用时://Student<double> stu2 = new Student<double>("张三", 90.5);//错误,必须是引用数据类型Student<Double> stu2 = new Student<Double>("张三", 90.5);//英语老师使用时:Student<Character> stu3 = new Student<Character>("张三", 'C');//错误的指定//Student<Object> stu = new Student<String>();//错误的}
}
JDK1.7支持简写形式:Student<String> stu1 = new Student<>("张三", "良好");
指定泛型实参时,必须左右两边一致,不存在多态现象

(3)在继承泛型类或实现泛型接口时,指定类型变量对应的实际类型参数

class ChineseStudent extends Student<String>{public ChineseStudent() {super();}public ChineseStudent(String name, String score) {super(name, score);}}
public class TestGeneric{public static void main(String[] args) {//语文老师使用时:ChineseStudent stu = new ChineseStudent("张三", "良好");}
}
class Circle implements Comparable<Circle>{private double radius;public Circle(double radius) {super();this.radius = radius;}public double getRadius() {return radius;}public void setRadius(double radius) {this.radius = radius;}@Overridepublic String toString() {return "Circle [radius=" + radius + "]";}@Overridepublic int compareTo(Circle c){return Double.compare(radius,c.radius);}}
类型变量的上限

当在声明类型变量时,如果不希望这个类型变量代表任意引用数据类型,而是某个系列的引用数据类型,那么可以设定类型变量的上限。

语法格式:

<类型变量  extends 上限>

如果有多个上限

<类型变量  extends 上限1 & 上限2>
如果多个上限中有类有接口,那么只能有一个类,而且必须写在最左边。接口的话,可以多个。
如果在声明<类型变量>时没有指定任何上限,默认上限是java.lang.Object。

例如:我们要声明一个两个数求和的工具类,要求两个加数必须是Number数字类型,并且实现Comparable接口。

class SumTools<T extends Number & Comparable<T>>{private T a;private T b;public SumTools(T a, T b) {super();this.a = a;this.b = b;}@SuppressWarnings("unchecked")public T getSum(){if(a instanceof BigInteger){return (T) ((BigInteger) a).add((BigInteger)b);}else if(a instanceof BigDecimal){return (T) ((BigDecimal) a).add((BigDecimal)b);}else if(a instanceof Short){return (T)(Integer.valueOf((Short)a+(Short)b));}else if(a instanceof Integer){return (T)(Integer.valueOf((Integer)a+(Integer)b));}else if(a instanceof Long){return (T)(Long.valueOf((Long)a+(Long)b));}else if(a instanceof Float){return (T)(Float.valueOf((Float)a+(Float)b));}else if(a instanceof Double){return (T)(Double.valueOf((Double)a+(Double)b));}throw new UnsupportedOperationException("不支持该操作");}
}

测试类

    public static void main(String[] args) {SumTools<Integer> s = new SumTools<Integer>(1,2);Integer sum = s.getSum();System.out.println(sum);//        SumTools<String> s = new SumTools<String>("1","2");//错误,因为String类型不是extends Number}
泛型擦除

当使用参数化类型的类或接口时,如果没有指定泛型,那么会怎么样呢?

会发生泛型擦除,自动按照最左边的第一个上限处理。如果没有指定上限,上限即为Object。

    public static void main(String[] args) {SumTools s = new SumTools(1,2);Number sum = s.getSum();System.out.println(sum);}
import java.util.Comparator;public class CircleComparator implements Comparator{@Overridepublic int compare(Object o1, Object o2) {//强制类型转换Circle c1 = (Circle) o1;Circle c2 = (Circle) o2;return Double.compare(c1.getRadius(), c2.getRadius());}}
public class TestExer1 {public static void main(String[] args) {Coordinate<String> c1 = new Coordinate<>("北纬38.6", "东经36.8");System.out.println(c1);//        Coordinate<Double> c2 = new Coordinate<>(38.6, 38);//自动装箱与拆箱只能与对应的类型 38是int,自动装为IntegerCoordinate<Double> c2 = new Coordinate<>(38.6, 36.8);System.out.println(c2);}
}
class Coordinate<T>{private T x;private T y;public Coordinate(T x, T y) {super();this.x = x;this.y = y;}public Coordinate() {super();}public T getX() {return x;}public void setX(T x) {this.x = x;}public T getY() {return y;}public void setY(T y) {this.y = y;}@Overridepublic String toString() {return "Coordinate [x=" + x + ", y=" + y + "]";}}

泛型方法

前面介绍了在定义类、接口时可以声明<类型变量>,在该类的方法和属性定义、接口的方法定义中,这些<类型变量>可被当成普通类型来用。但是,在另外一些情况下,

(1)如果我们定义类、接口时没有使用<类型变量>,但是某个方法定义时,想要自己定义<类型变量>;

(2)另外我们之前说类和接口上的类型形参是不能用于静态方法中,那么当某个静态方法想要定义<类型变量>。

那么,JDK1.5之后,还提供了泛型方法的支持。

语法格式:

【修饰符】 <类型变量列表> 返回值类型 方法名(【形参列表】)【throws 异常列表】{//...
}
<类型变量列表>:可以是一个或多个类型变量,一般都是使用单个的大写字母表示。例如:<T>、<K,V>等。
<类型变量>同样也可以指定上限

示例代码:

我们编写一个数组工具类,包含可以给任意对象数组进行从小到大排序,要求数组元素类型必须实现Comparable接口

public class MyArrays{public static <T extends Comparable<T>> void sort(T[] arr){for (int i = 1; i < arr.length; i++) {for (int j = 0; j < arr.length-i; j++) {if(arr[j].compareTo(arr[j+1])>0){T temp = arr[j];arr[j] = arr[j+1];arr[j+1] = temp;}}}}
}

测试类

public class TestGeneric{public static void main(String[] args) {int[] arr = {3,2,5,1,4};
//        MyArrays.sort(arr);//错误的,因为int[]不是对象数组String[] strings = {"hello","java","chai"};MyArrays.sort(strings);System.out.println(Arrays.toString(strings));Circle[] circles = {new Circle(2.0),new Circle(1.2),new Circle(3.0)};MyArrays.sort(circles);System.out.println(Arrays.toString(circles));}
}

类型通配符

当我们声明一个方法时,某个形参的类型是一个参数化的泛型类或泛型接口类型,但是在声明方法时,又不确定该泛型实际类型,我们可以考虑使用类型通配符。

<?>任意类型

例如:我们要声明一个学生管理类,这个管理类要包含一个方法,可以遍历学生数组。

学生管理类:

class StudentService {public static void print(Student<?>[] arr) {for (int i = 0; i < arr.length; i++) {System.out.println(arr[i]);}}
}

测试类

public class TestGeneric {public static void main(String[] args) {// 语文老师使用时:Student<String> stu1 = new Student<String>("张三", "良好");// 数学老师使用时:// Student<double> stu2 = new Student<double>("张三", 90.5);//错误,必须是引用数据类型Student<Double> stu2 = new Student<Double>("张三", 90.5);// 英语老师使用时:Student<Character> stu3 = new Student<Character>("张三", 'C');Student<?>[] arr = new Student[3];arr[0] = stu1;arr[1] = stu2;arr[2] = stu3;StudentService.print(arr);}
}
<? extends 上限>

例如:我们要声明一个学生管理类,这个管理类要包含一个方法,找出学生数组中成绩最高的学生对象。

要求学生的成绩的类型必须可比较大小,实现Comparable接口。

学生管理类:

class StudentService {@SuppressWarnings({ "rawtypes", "unchecked" })public static Student<? extends Comparable> max(Student<? extends Comparable>[] arr){Student<? extends Comparable> max = arr[0];for (int i = 0; i < arr.length; i++) {if(arr[i].getScore().compareTo(max.getScore())>0){max = arr[i];}}return max;}
}

测试类

public class TestGeneric {@SuppressWarnings({ "rawtypes", "unchecked" })public static void main(String[] args) {Student<? extends Double>[] arr = new Student[3];arr[0] = new Student<Double>("张三", 90.5);arr[1] = new Student<Double>("李四", 80.5);arr[2] = new Student<Double>("王五", 94.5);Student<? extends Comparable> max = StudentService.max(arr);System.out.println(max);}
}
<? super 下限>

现在要声明一个数组工具类,包含可以给任意对象数组进行从小到大排序,只要你指定定制比较器对象,而且这个定制比较器对象可以是当前数组元素类型自己或其父类的定制比较器对象

数组工具类:

class MyArrays{public static <T> void sort(T[] arr, Comparator<? super T> c){for (int i = 1; i < arr.length; i++) {for (int j = 0; j < arr.length-i; j++) {if(c.compare(arr[j], arr[j+1])>0){T temp = arr[j];arr[j] = arr[j+1];arr[j+1] = temp;}}}}
}

例如:有如下JavaBean

class Person{private String name;private int age;public Person(String name, int age) {super();this.name = name;this.age = age;}public Person() {super();}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}@Overridepublic String toString() {return "name=" + name + ", age=" + age;}
}
class Student extends Person{private int score;public Student(String name, int age, int score) {super(name, age);this.score = score;}public Student() {super();}public int getScore() {return score;}public void setScore(int score) {this.score = score;}@Overridepublic String toString() {return super.toString() + ",score=" + score;}}

测试类

public class TestGeneric {public static void main(String[] args) {Student[] all = new Student[3];all[0] = new Student("张三", 23, 89);all[1] = new Student("李四", 22, 99);all[2] = new Student("王五", 25, 67);MyArrays.sort(all, new Comparator<Person>() {@Overridepublic int compare(Person o1, Person o2) {return o1.getAge() - o2.getAge();}});System.out.println(Arrays.toString(all));MyArrays.sort(all, new Comparator<Student>() {@Overridepublic int compare(Student o1, Student o2) {return o1.getScore() - o2.getScore();}});System.out.println(Arrays.toString(all));}
}

使用类型通配符来指定类型参数的问题

<?>:不可变,因为<?>类型不确定,编译时,任意类型都是错

<? extends 上限>:不可变,因为<? extends 上限>的?可能是上限或上限的子类,即类型不确定,编译按任意类型处理都是错。

<? super 下限>:可以将值修改为下限或下限子类的对象,因为<? super 下限>?代表是下限或下限的父类,那么设置为下限或下限子类的对象是安全的。

public class TestGeneric {public static void main(String[] args) {Student<?> stu1 = new Student<>();stu1.setScore(null);//除了null,无法设置为其他值Student<? extends Number> stu2 = new Student<>();stu2.setScore(null);//除了null,无法设置为其他值Student<? super Number> stu3 = new Student<>();stu3.setScore(56);//可以设置Number或其子类的对象}
}
class Student<T>{private String name;private T score;public Student() {super();}public Student(String name, T score) {super();this.name = name;this.score = score;}public String getName() {return name;}public void setName(String name) {this.name = name;}public T getScore() {return score;}public void setScore(T score) {this.score = score;}@Overridepublic String toString() {return "姓名:" + name + ", 成绩:" + score;}
}

相关文章:

基础复习第二十二天 泛型的使用

泛型JDK1.5设计了泛型的概念。泛型即为“类型参数”&#xff0c;这个类型参数在声明它的类、接口或方法中&#xff0c;代表未知的通用的类型。例如&#xff1a;java.lang.Comparable接口和java.util.Comparator接口&#xff0c;是用于对象比较大小的规范接口&#xff0c;这两个…...

【C++进阶】三、二叉搜索树

目录 一、二叉搜索树 1.1 概念 1.2 二叉搜索树操作 二、二叉搜索树实现 2.1 框架总览 2.2 实现接口总览 2.2.1 构造函数 2.2.2 拷贝构造 2.2.3 赋值重载 2.2.4 析构函数 2.2.5 二叉搜索树的遍历 2.2.6 插入函数 2.2.7 查找函数 2.2.8 删除函数 2.3 二叉搜索数完整…...

电脑系统崩溃怎么修复教程

系统崩溃了怎么办? 如今的软件是越来越复杂、越来越庞大。由系统本身造成的崩溃即使是最简单的操作&#xff0c;比如关闭系统或者是对BIOS进行升级都可能会对PC合操作系统造成一定的影响。下面一起来看看电脑系统崩溃修复方法步骤。 工具/原料&#xff1a; 系统版本&#xf…...

语义分割数据标注案例分析

语义分割&#xff08;Semantic Segmentation&#xff09;是计算机视觉领域中的一种重要任务&#xff0c;它的目的是将图像中的每个像素分配到对应的语义类别中。简单来说&#xff0c;就是将一张图像分割成多个区域&#xff0c;并为每个像素指定一个标签&#xff0c;标识出它属于…...

回归预测 | MATLAB实现GRU(门控循环单元)多输入单输出(多指标评价)

回归预测 | MATLAB实现GRU(门控循环单元)多输入单输出(多指标评价) 文章目录 回归预测 | MATLAB实现GRU(门控循环单元)多输入单输出(多指标评价)预测效果基本介绍程序设计参考资料预测效果 基本介绍 GRU神经网络是LST...

驱动程序开发:Buildroot根文件系统构建并加载驱动文件xxx.ko测试

目录一、buildroot根文件系统简介二、buildroot下载三、buildroot构建根文件系统1、配置 buildroot①配置 Target options②配置 Toolchain③配置 System configuration④配置 Filesystem images⑤禁止编译 Linux 内核和 uboot2、 buildroot 下的 busybox 配置①修改 Makefile&…...

R+VIC模型融合实践技术应用及未来气候变化模型预测

目录 理论专题一&#xff1a;VIC模型的原理及特点 综合案例一&#xff1a;基于QGIS的VIC模型建模 理论专题二&#xff1a;VIC模型率定验证 综合案例二&#xff1a;基于R语言VIC参数率定和优化 理论专题三&#xff1a;遥感技术与未来气候变化 综合案例三&#xff1a;运用V…...

第六章.决策树(Decision Tree)—ID3算法,C4.5算法

第六章.决策树(Decision Tree) 6.1 ID3算法,C4.5算法 1.决策树适用的数据类型 比较适合分析离散数据&#xff0c;如果是连续数据要先转换成离散数据再做分析 2.信息熵 1).概念&#xff1a; 一条信息的信息量大小和它的不确定性有直接的关系&#xff0c;要搞清楚一件非常不确…...

springboot+pgbouncer+postgres数据库连接池集成方案及问题解决

期望通过每一次分享&#xff0c;让技术的门槛变低&#xff0c;落地更容易。 —— around 前言 旨在解决微服务项目全是连接池并影响数据库并发连接&#xff0c;作者的环境是基于sprongboot微服务连接postgres数据库&#xff0c;每个微服务的DAO层配置都使用了连接池技术。后续…...

Mysql 常用日期处理函数

Mysql 常用日期处理函数 1 建表语句 SET NAMES utf8mb4; SET FOREIGN_KEY_CHECKS 0; -- ---------------------------- -- Table structure for emp -- ---------------------------- DROP TABLE IF EXISTS emp; CREATE TABLE emp (EMPNO int(4) NOT NULL,ENAME varchar(10…...

Pod中容器的健康检查

健康检查 上篇文章中我们了解了Pod中容器的生命周期的两个钩子函数&#xff0c;PostStart与PreStop&#xff0c;其中PostStart是在容器创建后立即执行的&#xff0c;而PreStop这个钩子函数则是在容器终止之前执行的。除了上面这两个钩子函数以外&#xff0c;还有一项配置会影响…...

信贷系统学习总结(5)—— 简单的风控示例(含代码)

一、背景1.为什么要做风控?目前我们业务有使用到非常多的AI能力,如ocr识别、语音测评等,这些能力往往都比较费钱或者费资源,所以在产品层面也希望我们对用户的能力使用次数做一定的限制,因此风控是必须的!2.为什么要自己写风控?那么多开源的风控组件,为什么还要写呢?是不是想…...

Java知识复习(四)多线程、并发编程

1、进程、线程和程序 进程&#xff1a;进程是程序的一次执行过程&#xff0c;是系统运行程序的基本单位&#xff0c;因此进程是动态的&#xff1b;在 Java 中&#xff0c;当我们启动 main 函数时其实就是启动了一个 JVM 的进程&#xff0c;而 main 函数所在的线程就是这个进程…...

一个9个月测试经验的人,居然在面试时跟我要18K,我都被他吓到了····

2月初我入职了深圳某家创业公司&#xff0c;刚入职还是很兴奋的&#xff0c;到公司一看我傻了&#xff0c;公司除了我一个测试&#xff0c;公司的开发人员就只有3个前端2个后端还有2个UI&#xff0c;在粗略了解公司的业务后才发现是一个从零开始的项目&#xff0c;目前啥都没有…...

zigbee与WIFI同频干扰问题

zigbee与WIFI同频干扰 为了降低Wifi信道与Zigbee信道的同频干扰问题&#xff0c;Zigbee联盟在《Zigbee Home Automation Public Application Profile》中推荐使用11,14,15,19,20,24,25这七个信道。 为什么呢&#xff0c;我们看一下Wifi和Zigbee的信道分布。 WiFi带宽对干扰的…...

git拉取指定的单个或多个文件或文件夹

直接上步骤 初始化仓库 git init拉取远程仓库信息&#xff0c;省略号为仓库地址 git remote add -f origin http://****.git开启 sparse clone git config core.sparsecheckout true配置需要拉取的文件夹 有一个指定一个&#xff0c;有多个指定多个&#xff0c;路径写对即可&a…...

不是,到底有多少种图片懒加载方式?

一、也是我最开始了解到的 js方法&#xff0c;利用滚动事件&#xff0c;判断当时的图片位置是否在可视框内&#xff0c;然后进行渲染。 弊端&#xff1a;代码冗杂&#xff0c;你还要去监听页面的滚动事件&#xff0c;这本身就是一个不建议监听的事件&#xff0c;即便是我们做了…...

CAD坐标有哪些输入方式?来看看这些CAD坐标输入方式!

在CAD设计过程中&#xff0c;有时需要通过已知坐标点来画图&#xff0c;有时又需要通过已知角度和距离来画图&#xff0c;在这种情况下&#xff0c;由于已知条件不同&#xff0c;所以便需要用不同的方式来定位点。那么&#xff0c;你知道CAD坐标有哪些输入方式吗&#xff1f;本…...

铰链、弹簧,特殊的物理关节

title: 铰链、弹簧&#xff0c;特殊的物理关节 date: 2023-02-28T13:32:57Z lastmod: 2023-02-28T14:24:06Z 铰链关节&#xff08;Hinge Join&#xff09;组件 组件-Physics-Hinge Join Anchor 当物体挂载铰链组件以后&#xff0c;组件下Anchor等同于边长为1的立方体。当这…...

Android Studio相关记录

目录Android Studio 便捷插件Android LogcatJava文件的类头模板Android Studio 使用遇到的问题解决方案org.jetbrains.annotations.NullableBuild 控制台编译输出中文乱码Terminal 使用 git 命令窗口git 命令窗口中文乱码Android Studio 便捷插件 Android Logcat 配置路径 Fi…...

8k长序列建模,蛋白质语言模型Prot42仅利用目标蛋白序列即可生成高亲和力结合剂

蛋白质结合剂&#xff08;如抗体、抑制肽&#xff09;在疾病诊断、成像分析及靶向药物递送等关键场景中发挥着不可替代的作用。传统上&#xff0c;高特异性蛋白质结合剂的开发高度依赖噬菌体展示、定向进化等实验技术&#xff0c;但这类方法普遍面临资源消耗巨大、研发周期冗长…...

【SpringBoot】100、SpringBoot中使用自定义注解+AOP实现参数自动解密

在实际项目中,用户注册、登录、修改密码等操作,都涉及到参数传输安全问题。所以我们需要在前端对账户、密码等敏感信息加密传输,在后端接收到数据后能自动解密。 1、引入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId...

令牌桶 滑动窗口->限流 分布式信号量->限并发的原理 lua脚本分析介绍

文章目录 前言限流限制并发的实际理解限流令牌桶代码实现结果分析令牌桶lua的模拟实现原理总结&#xff1a; 滑动窗口代码实现结果分析lua脚本原理解析 限并发分布式信号量代码实现结果分析lua脚本实现原理 双注解去实现限流 并发结果分析&#xff1a; 实际业务去理解体会统一注…...

七、数据库的完整性

七、数据库的完整性 主要内容 7.1 数据库的完整性概述 7.2 实体完整性 7.3 参照完整性 7.4 用户定义的完整性 7.5 触发器 7.6 SQL Server中数据库完整性的实现 7.7 小结 7.1 数据库的完整性概述 数据库完整性的含义 正确性 指数据的合法性 有效性 指数据是否属于所定…...

HybridVLA——让单一LLM同时具备扩散和自回归动作预测能力:训练时既扩散也回归,但推理时则扩散

前言 如上一篇文章《dexcap升级版之DexWild》中的前言部分所说&#xff0c;在叠衣服的过程中&#xff0c;我会带着团队对比各种模型、方法、策略&#xff0c;毕竟针对各个场景始终寻找更优的解决方案&#xff0c;是我个人和我司「七月在线」的职责之一 且个人认为&#xff0c…...

阿里云Ubuntu 22.04 64位搭建Flask流程(亲测)

cd /home 进入home盘 安装虚拟环境&#xff1a; 1、安装virtualenv pip install virtualenv 2.创建新的虚拟环境&#xff1a; virtualenv myenv 3、激活虚拟环境&#xff08;激活环境可以在当前环境下安装包&#xff09; source myenv/bin/activate 此时&#xff0c;终端…...

WEB3全栈开发——面试专业技能点P7前端与链上集成

一、Next.js技术栈 ✅ 概念介绍 Next.js 是一个基于 React 的 服务端渲染&#xff08;SSR&#xff09;与静态网站生成&#xff08;SSG&#xff09; 框架&#xff0c;由 Vercel 开发。它简化了构建生产级 React 应用的过程&#xff0c;并内置了很多特性&#xff1a; ✅ 文件系…...

TCP/IP 网络编程 | 服务端 客户端的封装

设计模式 文章目录 设计模式一、socket.h 接口&#xff08;interface&#xff09;二、socket.cpp 实现&#xff08;implementation&#xff09;三、server.cpp 使用封装&#xff08;main 函数&#xff09;四、client.cpp 使用封装&#xff08;main 函数&#xff09;五、退出方法…...

Python学习(8) ----- Python的类与对象

Python 中的类&#xff08;Class&#xff09;与对象&#xff08;Object&#xff09;是面向对象编程&#xff08;OOP&#xff09;的核心。我们可以通过“类是模板&#xff0c;对象是实例”来理解它们的关系。 &#x1f9f1; 一句话理解&#xff1a; 类就像“图纸”&#xff0c;对…...

【Java】Ajax 技术详解

文章目录 1. Filter 过滤器1.1 Filter 概述1.2 Filter 快速入门开发步骤:1.3 Filter 执行流程1.4 Filter 拦截路径配置1.5 过滤器链2. Listener 监听器2.1 Listener 概述2.2 ServletContextListener3. Ajax 技术3.1 Ajax 概述3.2 Ajax 快速入门服务端实现:客户端实现:4. Axi…...