201871010128-杨丽霞《面向对象程序设计(Java)》第十一周学习总结

项目

内容

这个作业属于哪个课程

https://www.cnblogs.com/nwnu-daizh/

这个作业的要求在哪里

https://www.cnblogs.com/nwnu-daizh/p/11815810.html

作业学习目标

  1. 理解泛型概念;
  2. 掌握泛型类的定义与使用;
  3. 掌握泛型方法的声明与使用;
  4. 掌握泛型接口的定义与实现;
  5. 了解泛型程序设计,理解其用途

第一部分:总结第八章关于泛型程序设计理论知识(25分)

1.什么是泛型程序设计?

JDK 5.0 中增加的泛型类型,是 Java 语言中类型安全的一次重要改进。

泛型:也称参数化类型(parameterized type),就是在定义类、接口和方法时,通过类型参数指
示将要处理的对象类型。(如ArrayList类)

泛型程序设计(Generic programming):编写代码可以被很多不同类型的对象所重用。

2、类型参数的优点

改善程序可读性

增强类型使用安全性

3.泛型类的定义

一个泛型类就是具有一个或多个类型变量的类,即创建用类型作为参数的类。如一个泛型类定义格式为class Generics<K,V>

其中K和V是类的可变类型参数。

泛型类可以有多个类型变量 例如:public Pair<T,U>{...}

泛型方法的声明:除了泛型类外,还可以只单独定义一个方法做为泛型方法,用于指定方法参数或者返回值为泛型类型,留待方法调用时确定。泛型方法可以申明在泛型类中,也可以声明在普通类中。

4.泛型接口的定义:

public interface IPool<T>

{

T get();

int add(T t);

}

5.泛型变量的限定:定义泛型变量的上界,泛型变量上界的说明上述声明规定了NumberGeneric类所能处理的泛型变量类型需和Number有继承关系,extends关键字所声明的上界既可以是一个类,也可以是一个接口

泛型变量下界的说明 通过使用super关键字可以固定泛型参数的类型为某种类型的超类 当希望为一个方法的参数限定类型时常可以使用下限通配符
6.通配符类型:
单独的?表示任何类型
?extends type,表示带有上界
?supre type,表示带有下界
7.泛型的约束和局限性

1). 不能使用基本数据类型实例化类型参数

不能使用类型参数代替基本数据。因此,没有Pair<double>,只有Pair<Double>(这里我们假设Pair是一个public class Pair<T> 类型的一个类)。这个非常的好理解,想一想我们在使用List集合时,不能这样子来定义一个集合:List<int> list = new ArrayList<>(),通常都是这样来定义一个int类型的集合:List<Integer> list = new ArrayList<>();

Java泛型的类型擦除

在我们定义一个泛型类的时候,都会自动的给我们提供一个相应的原始类型(这个原始类型不是像Integer对应的是原始数据类型是int)。这里的原始数据类型就是删除类型参数之后的泛型类型名、擦除类型变量,并且替换为限定类型(如果没有限定类型,那么就用Object来代替)。

2).运行时类型查询只适用于原始类型

在Java中,我们知道可以使用instanceof关键字来判断一个引用是否是一个类的对象。在泛型里面,这种代码是不支持的:

if(a instanceof Pair<String>)

或者是强制类型转换:

Pair<String> p = (Pair<String>)a;

同样的道理,使用getClass方法返回的原始类型:

Pair<String> stringPair = new Pair<>();
Pair<Integer> integerPair = new Pair<>();

3). 不能创建泛型类型的数组

不能创建泛型类型的数组,例如:

Pair<String> pairs[] = new Pairs<String>[10];

4).Varagrs警告

5.) 不能创建泛型类型的变量

不能使用像new T(...)、new T[...]或者T.class这样的表达式

8.反射和泛型

Java采用泛型擦除的机制来引入泛型。Java中的泛型仅仅是给编译器javac使用的, 确保数据的安全性和免去强制类型转换的麻烦 。但是,__一旦编译完成,所有的和泛型有关的类型全部擦除__。

为了通过反射操作这些类型以迎合实际开发的需要,Java就新增了ParameterizedType,GenericArrayType,TypeVariable 和WildcardType几种类型来代表不能被归一到Class类中的类型但是又和原始类型齐名的类型。

  • ParameterizedType: 表示一种参数化的类型,比如Collection<String>
  • GenericArrayType: 表示一种元素类型是参数化类型或者类型变量的数组类型
  • TypeVariable: 是各种类型变量的公共父接口
  • WildcardType: 代表一种通配符类型表达

第二部分:实验部分

实验1:测试程序1(6分)

编辑、调试、运行教材311312页代.码,结合程序运行结果理解程序;

在泛型类定义及使用代码处添加注释;

掌握泛型类的定义及使用。

/**
* @version 1.01 2012-01-26
* @author Cay Horstmann
*/
public class PairTest1
{
public static void main(String[] args)
{
String[] words = { "Mary", "had", "a", "little", "lamb" };//初始化一个String对象数组
Pair<String> mm = ArrayAlg.minmax(words);//一对字符串:min,max
System.out.println("min = " + mm.getFirst());
System.out.println("max = " + mm.getSecond());
}
} class ArrayAlg
{
/**
* Gets the minimum and maximum of an array of strings.
* @param a an array of strings
* @return a pair with the min and max value, or null if a is null or empty
*/
public static Pair<String> minmax(String[] a)//普通方法,定义minmax为字符串类型
{
if (a == null || a.length == ) return null;
String min = a[];
String max = a[];
//将元素的泛型具体声明 for (int i = ; i < a.length; i++)//length:数组属性值
{
if (min.compareTo(a[i]) > ) min = a[i];
if (max.compareTo(a[i]) < ) max = a[i];
}//实现字符串比较大小
return new Pair<>(min, max);
}
}
/**
* @version 1.00 2004-05-10
* @author Cay Horstmann
*/
public class Pair<T>//类型变量(放在类名后面)
{
private T first;
private T second; public Pair() { first = null; second = null; }
public Pair(T first, T second) { this.first = first; this.second = second; } public T getFirst() { return first; }
public T getSecond() { return second; } public void setFirst(T newValue) { first = newValue; }
public void setSecond(T newValue) { second = newValue; }
}

运行截图:

实验1:测试程序2(6分)

编辑、调试运行教材315 PairTest2,结合程序运行结果理解程序;

在泛型程序设计代码处添加相关注释;

了解泛型方法、泛型变量限定的定义及用途。

import java.time.*;

/**
* @version 1.02 2015-06-21
* @author Cay Horstmann
*/
public class PairTest2
{
public static void main(String[] args)
{
LocalDate[] birthdays =
{
LocalDate.of(, , ), // G. Hopper
LocalDate.of(, , ), // A. Lovelace
LocalDate.of(, , ), // J. von Neumann
LocalDate.of(, , ), // K. Zuse
};
Pair<LocalDate> mm = ArrayAlg.minmax(birthdays);
System.out.println("min = " + mm.getFirst());
System.out.println("max = " + mm.getSecond());
}
} class ArrayAlg
{
/**
Gets the minimum and maximum of an array of objects of type T.
@param a an array of objects of type T
@return a pair with the min and max value, or null if a is
null or empty
*/
public static <T extends Comparable> Pair<T> minmax(T[] a) //泛型方法(comparable是T的上界约束)
{
if (a == null || a.length == ) return null;
T min = a[];
T max = a[];//min和max与T的类型一致
for (int i = ; i < a.length; i++)
{
if (min.compareTo(a[i]) > ) min = a[i];
if (max.compareTo(a[i]) < ) max = a[i];
}
return new Pair<>(min, max);
}
}
/**
* @version 1.00 2004-05-10
* @author Cay Horstmann
*/
public class Pair<T> //类型变量
{
private T first;
private T second; public Pair() { first = null; second = null; }
public Pair(T first, T second) { this.first = first; this.second = second; } public T getFirst() { return first; }
public T getSecond() { return second; } public void setFirst(T newValue) { first = newValue; }
public void setSecond(T newValue) { second = newValue; }
}

运行截图:

实验1:测试程序3(6分)

用调试运行教材335 PairTest3,结合程序运行结果理解程序;

了解通配符类型的定义及用途。

/**
* @version 1.01 2012-01-26
* @author Cay Horstmann
*/
public class PairTest3
{
public static void main(String[] args)
{
Manager ceo = new Manager("Gus Greedy", , , , );
Manager cfo = new Manager("Sid Sneaky", , , , );
Pair<Manager> buddies = new Pair<>(ceo, cfo);
printBuddies(buddies); ceo.setBonus();
cfo.setBonus();
Manager[] managers = { ceo, cfo }; Pair<Employee> result = new Pair<>(); minmaxBonus(managers, result);
System.out.println("first: " + result.getFirst().getName()
+ ", second: " + result.getSecond().getName());
maxminBonus(managers, result);
System.out.println("first: " + result.getFirst().getName()
+ ", second: " + result.getSecond().getName());
} public static void printBuddies(Pair<? extends Employee> p)//通配符类型(带有上界)extends关键字所声明的上界既可以是一个类,也可以是一个接口。
{
Employee first = p.getFirst();
Employee second = p.getSecond();
System.out.println(first.getName() + " and " + second.getName() + " are buddies.");
} public static void minmaxBonus(Manager[] a, Pair<? super Manager> result)//通配符类型(带有下界)必须是Manager的子类
{
if (a.length == ) return;
Manager min = a[];
Manager max = a[];
for (int i = ; i < a.length; i++)
{
if (min.getBonus() > a[i].getBonus()) min = a[i];
if (max.getBonus() < a[i].getBonus()) max = a[i];
}//比较大小值
result.setFirst(min);
result.setSecond(max);
} public static void maxminBonus(Manager[] a, Pair<? super Manager> result)//通配符类型(带有下界)
{
minmaxBonus(a, result);
PairAlg.swapHelper(result); //swapHelper捕获通配符类型
}
//无法编写公共静态< T超级管理器>
} class PairAlg
{
public static boolean hasNulls(Pair<?> p)//通过将hasNulls转换成泛型方法,避免使用通配符类型
{
return p.getFirst() == null || p.getSecond() == null;
} public static void swap(Pair<?> p) { swapHelper(p); } public static <T> void swapHelper(Pair<T> p)//使用辅助方法swapHelper(泛型方法),以在交换时临时保存第一个元素
{
T t = p.getFirst();
p.setFirst(p.getSecond());
p.setSecond(t);
}
}
/**
* @version 1.01 2012-01-26
* @author Cay Horstmann
*/
public class PairTest3
{
public static void main(String[] args)
{
Manager ceo = new Manager("Gus Greedy", , , , );
Manager cfo = new Manager("Sid Sneaky", , , , );
Pair<Manager> buddies = new Pair<>(ceo, cfo);
printBuddies(buddies); ceo.setBonus();
cfo.setBonus();
Manager[] managers = { ceo, cfo }; Pair<Employee> result = new Pair<>(); minmaxBonus(managers, result);
System.out.println("first: " + result.getFirst().getName()
+ ", second: " + result.getSecond().getName());
maxminBonus(managers, result);
System.out.println("first: " + result.getFirst().getName()
+ ", second: " + result.getSecond().getName());
} public static void printBuddies(Pair<? extends Employee> p)//通配符类型(带有上界)extends关键字所声明的上界既可以是一个类,也可以是一个接口。
{
Employee first = p.getFirst();
Employee second = p.getSecond();
System.out.println(first.getName() + " and " + second.getName() + " are buddies.");
} public static void minmaxBonus(Manager[] a, Pair<? super Manager> result)//通配符类型(带有下界)必须是Manager的子类
{
if (a.length == ) return;
Manager min = a[];
Manager max = a[];
for (int i = ; i < a.length; i++)
{
if (min.getBonus() > a[i].getBonus()) min = a[i];
if (max.getBonus() < a[i].getBonus()) max = a[i];
}//比较大小值
result.setFirst(min);
result.setSecond(max);
} public static void maxminBonus(Manager[] a, Pair<? super Manager> result)//通配符类型(带有下界)
{
minmaxBonus(a, result);
PairAlg.swapHelper(result); //swapHelper捕获通配符类型
}
//无法编写公共静态< T超级管理器>
} class PairAlg
{
public static boolean hasNulls(Pair<?> p)//通过将hasNulls转换成泛型方法,避免使用通配符类型
{
return p.getFirst() == null || p.getSecond() == null;
} public static void swap(Pair<?> p) { swapHelper(p); } public static <T> void swapHelper(Pair<T> p)//使用辅助方法swapHelper(泛型方法),以在交换时临时保存第一个元素
{
T t = p.getFirst();
p.setFirst(p.getSecond());
p.setSecond(t);
}
}
/**
* @version 1.00 2004-05-10
* @author Cay Horstmann
*/
public class Pair<T>
{
private T first;
private T second;
//T是未知类型,不代表值
public Pair() { first = null; second = null; }
public Pair(T first, T second) { this.first = first; this.second = second; } public T getFirst() { return first; }
public T getSecond() { return second; } public void setFirst(T newValue) { first = newValue; }
public void setSecond(T newValue) { second = newValue; }
}
import java.time.*;

public class Employee//用户自定义类
{
private String name;
private double salary;
private LocalDate hireDay; public Employee(String name, double salary, int year, int month, int day)
{
this.name = name;
this.salary = salary;
hireDay = LocalDate.of(year, month, day);
} public String getName()
{
return name;
} public double getSalary()
{
return salary;
} public LocalDate getHireDay()
{
return hireDay;
} public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / ;
salary += raise;
}
}
public class Manager extends Employee//继承类
{
private double bonus; /**
@param name the employee's name
@param salary the salary
@param year the hire year
@param month the hire month
@param day the hire day
*/
public Manager(String name, double salary, int year, int month, int day)
{
super(name, salary, year, month, day);
bonus = ;
} public double getSalary()
{
double baseSalary = super.getSalary();
return baseSalary + bonus;
} public void setBonus(double b)
{
bonus = b;
} public double getBonus()
{
return bonus;
}
}

运行截图:

实验2:结对编程练习(32分)

结对编程练习,将程序提交到PTA(2019面向对象程序设计基础知识测试题(2)

1 编写一个泛型接口GeneralStack,要求类方法对任何引用类型数据都适用。GeneralStack接口中方法如下:

push(item);            //如item为null,则不入栈直接返回null。
pop(); //出栈,如为栈为空,则返回null。
peek(); //获得栈顶元素,如为空,则返回null.
public boolean empty();//如为空返回true
public int size(); //返回栈中元素数量

2定义GeneralStack的类ArrayListGeneralStack要求:

ü 类内使用ArrayList对象存储堆栈数据,名为list;

ü 方法: public String toString()//代码为return list.toString();

ü 代码中不要出现类型不安全的强制转换。

3定义Car类,类的属性有:

private int id;
private String name;

方法:Eclipse自动生成setter/getter,toString方法。

4main方法要求

ü 输入选项,有quit, Integer, Double, Car 4个选项。如果输入quit,程序直接退出。否则,输入整数m与n。m代表入栈个数,n代表出栈个数。然后声明栈变量stack。

ü 输入Integer,打印Integer Test。建立可以存放Integer类型的ArrayListGeneralStack。入栈m次,出栈n次。打印栈的toString方法。最后将栈中剩余元素出栈并累加输出。

ü 输入Double ,打印Double Test。剩下的与输入Integer一样。

ü 输入Car,打印Car Test。其他操作与Integer、Double基本一样。只不过最后将栈中元素出栈,并将其name依次输出。

特别注意:如果栈为空,继续出栈,返回null

输入样例

Integer

Double

1.1 2.0 4.9 5.7 7.2
Car Ford
Cherry
BYD
quit

输出样例:

Integer Test

push:1

push:2

push:3

push:4

push:5

pop:5

pop:4

[1, 2, 3]

sum=6

interface GeneralStack

Double Test

push:1.1

push:2.0

push:4.9

push:5.7

push:7.2

pop:7.2

pop:5.7

pop:4.9

[1.1, 2.0]

sum=3.1

interface GeneralStack

Car Test

push:Car [id=1, name=Ford]

push:Car [id=2, name=Cherry]

push:Car [id=3, name=BYD]

pop:Car [id=3, name=BYD]

pop:Car [id=2, name=Cherry]

[Car [id=1, name=Ford]]

Ford

interface GeneralStack

程序如下:

import java.util.ArrayList;
import java.util.Scanner; interface GeneralStack<T>{
public T push(T item);
public T pop();
public T peek();
public boolean empty();
public int size(); //
}
class ArrayListGeneralStack implements GeneralStack{ //创建一个实现GeneralStack接口的类
ArrayList list=new ArrayList();
@Override//重写toString方法
public String toString() {
return list.toString();
} @Override//重写压栈方法
public Object push(Object item) {
if (list.add(item)){
return item;
}else {
return false;
}
} @Override//重写出栈方法
public Object pop() {
if (list.size()==){//判断栈为空时,返回null
return null;
}
return list.remove(list.size()-);
} @Override//重写获取栈顶元素的函数
public Object peek() {
return list.get(list.size()-);
} @Override
public boolean empty() {//栈为空时,直接返回boolean值
if (list.size()==){
return true;
}else {
return false;
}
} @Override//重写得到栈中元素个数的函数
public int size() {
return list.size();
}
}
class Car{//定义一个Car类
private int id;//两个私有属性
private String name; @Override
public String toString() {
return "Car [" +
"id=" + id +
", name=" + name +
']';
} public int getId() {
return id;
} public void setId(int id) {
this.id = id;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public Car(int id, String name) {
this.id = id;
this.name = name;
}
}
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while (true){
String s=sc.nextLine();//输入选项,有quit, Integer, Double, Car 4个选项。
if (s.equals("Double")){//输入Double ,打印Double Test。
System.out.println("Double Test");
int count=sc.nextInt();
int pop_time=sc.nextInt();
ArrayListGeneralStack arrayListGeneralStack = new ArrayListGeneralStack();//建立可以存放Double类型的ArrayListGeneralStack。
for (int i=;i<count;i++){//入栈次数
System.out.println("push:"+arrayListGeneralStack.push(sc.nextDouble()));
}
for (int i=;i<pop_time;i++){//出栈次数
System.out.println("pop:"+arrayListGeneralStack.pop());
}
System.out.println(arrayListGeneralStack.toString());//打印栈的toString方法
double sum=;
int size=arrayListGeneralStack.size();
for (int i=;i<size;i++){
sum+=(double)arrayListGeneralStack.pop();//最后将栈中剩余元素出栈并累加输出。
}
System.out.println("sum="+sum);
System.out.println("interface GeneralStack");
}else if (s.equals("Integer")){ //输入Integer,打印Integer Test。
System.out.println("Integer Test");
int count=sc.nextInt();
int pop_time=sc.nextInt();
ArrayListGeneralStack arrayListGeneralStack = new ArrayListGeneralStack(); //输入Integer,打印Integer Test。
for (int i=;i<count;i++){ //入栈次数
System.out.println("push:"+arrayListGeneralStack.push(sc.nextInt()));
}
for (int i=;i<pop_time;i++){//出栈次数
System.out.println("pop:"+arrayListGeneralStack.pop());
}
System.out.println(arrayListGeneralStack.toString()); //打印栈的toString方法。
int sum=;
int size=arrayListGeneralStack.size();
for (int i=;i<size;i++){
sum+=(int)arrayListGeneralStack.pop();//最后将栈中剩余元素出栈并累加输出。
}
System.out.println("sum="+sum);
System.out.println("interface GeneralStack");
}else if (s.equals("Car")){//输入Car,打印Car Test
System.out.println("Car Test");
int count=sc.nextInt();
int pop_time=sc.nextInt();
ArrayListGeneralStack arrayListGeneralStack = new ArrayListGeneralStack();//创建可以存放Car类型的ArrayListGeneralStack。
for (int i=;i<count;i++){
int id=sc.nextInt();
String name=sc.next();
Car car = new Car(id,name);
System.out.println("push:"+arrayListGeneralStack.push(car));
}
for (int i=;i<pop_time;i++){//出栈次数
System.out.println("pop:"+arrayListGeneralStack.pop());
}
System.out.println(arrayListGeneralStack.toString());
if (arrayListGeneralStack.size()>){
int size=arrayListGeneralStack.size();
for (int i=;i<size;i++){
Car car=(Car) arrayListGeneralStack.pop();//将栈中元素出栈,并将其name依次输出。
System.out.println(car.getName());
}
}
System.out.println("interface GeneralStack");
}else if (s.equals("quit")){//如果输入quit,程序直接退出。
break;
}
} }
}

运行结果:

实验总结:(15分)

本周学习了泛型类了解了其概念,学习了泛型的定义与使用,泛型方法的声明等,刚接触上理论课的时候可能不太能理解,但是通过程序测试可以体会泛型设计的用途,这周通过学长演示如何写小学生除法练习编程,让我对如何编写一个完整的程序有了整体的了解,并且通过演示体会到未检查异常和已检查异常的区别,以及在自己练习中如何去避免和处理异常。之后会自己多加练习,来巩固知识点。

201871010128-杨丽霞《面向对象程序设计(Java)》第十一周学习总结的更多相关文章

  1. 201771010134杨其菊《面向对象程序设计java》第九周学习总结

                                                                      第九周学习总结 第一部分:理论知识 异常.断言和调试.日志 1.捕获 ...

  2. 201871010132-张潇潇《面向对象程序设计(java)》第一周学习总结

    面向对象程序设计(Java) 博文正文开头 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cn ...

  3. 扎西平措 201571030332《面向对象程序设计 Java 》第一周学习总结

    <面向对象程序设计(java)>第一周学习总结 正文开头: 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 ...

  4. 杨其菊201771010134《面向对象程序设计Java》第二周学习总结

    第三章 Java基本程序设计结构 第一部分:(理论知识部分) 本章主要学习:基本内容:数据类型:变量:运算符:类型转换,字符串,输入输出,控制流程,大数值以及数组. 1.基本概念: 1)标识符:由字母 ...

  5. 201871010124 王生涛《面向对象程序设计JAVA》第一周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://edu.cnblogs.com/campus/xbsf/ ...

  6. 201871010115——马北《面向对象程序设计JAVA》第二周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  7. 201777010217-金云馨《面向对象程序设计(Java)》第二周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  8. 201871010132——张潇潇《面向对象程序设计JAVA》第二周学习总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  9. 201771010123汪慧和《面向对象程序设计Java》第二周学习总结

    一.理论知识部分 1.标识符由字母.下划线.美元符号和数字组成, 且第一个符号不能为数字.标识符可用作: 类名.变量名.方法名.数组名.文件名等.第二部分:理论知识学习部分 2.关键字就是Java语言 ...

  10. 20172325 2017-2018-2 《Java程序设计》第十一周学习总结

    20172325 2017-2018-2 <Java程序设计>第十一周学习总结 教材学习内容总结 Android简介 Android操作系统是一种多用户的Linux系统,每个应用程序作为单 ...

随机推荐

  1. LG4341/BZOJ2251 「BJWC2010」外星联络 Trie

    问题描述 LG4341 BZOJ2251 BZOJ需要权限号 题解 字符串的性质:一个字符串\(s\)所有的字串,等于\(s\)所有后缀的前缀. 枚举这个字符串的每一个后缀,将其插入一个\(\math ...

  2. 设计模式-Builder模式(创建型模式)

    //以下代码来源: 设计模式精解-GoF 23种设计模式解析附C++实现源码 //Product.h #pragma once class Product { public: Product(); ~ ...

  3. 【CometOJ】Comet OJ - Contest #8 解题报告

    点此进入比赛 \(A\):杀手皇后(点此看题面) 大致题意: 求字典序最小的字符串. 一场比赛总有送分题... #include<bits/stdc++.h> #define Tp tem ...

  4. [LeetCode] 238. Product of Array Except Self 除本身之外的数组之积

    Given an array nums of n integers where n > 1,  return an array output such that output[i] is equ ...

  5. JAVA基础系列:反射

    1. 定义 在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对于任意一个对象,都能够调用它的任意一个方法:这 种动态获取的信息以及动态调用对象的方法的功能称为java语言的反射机制. ...

  6. webrtc笔记(3): 多人视频通讯常用架构Mesh/MCU/SFU

    问题:为什么要搞这么多架构? webrtc虽然是一项主要使用p2p的实时通讯技术,本应该是无中心化节点的,但是在一些大型多人通讯场景,如果都使用端对端直连,端上会遇到很带宽和性能的问题,所以就有了下图 ...

  7. 使用selenium爬虫抓取数据

    写在前面 本来这篇文章该几个月前写的,后来忙着忙着就给忘记了.ps:事多有时候反倒会耽误事.几个月前,记得群里一朋友说想用selenium去爬数据,关于爬数据,一般是模拟访问某些固定网站,将自己关注的 ...

  8. 解决centos ssh连接很慢的问题

    更改配置文件vi /etc/ssh/sshd_config找到UseDNS 将UseDNS前面的#删除,并将YES改为NO,若找不到UseDNS,则手动添加UseDNS,并将其设置成No保存并重启ss ...

  9. NXP官方ddr_stress_tester工具使用

    1.前言 NXP官方提供了一个DDR初始化工具,名称为ddr_stress_tester,该工具具有以下特点: 该工具能通过USB OTG接口与目标板进行连接,通过USB OTG接口完成DDR的初始化 ...

  10. 如何自动生成 Entity Framework 的 Mapping 文件?

    Program.cs using System; using System.IO; using System.Text; using System.Text.RegularExpressions; n ...