201871010135   张玉晶 《面向对象程序设计(java)》第八周学习总结》

项目

内容

这个作业属于哪个课程

<任课教师博客主页链接> https://www.cnblogs.com/nwnu-daizh/

这个作业的要求在哪里

<作业链接地址>https://www.cnblogs.com/nwnu-daizh/p/11703678.html

作业学习目标

  1. 掌握接口定义方法;
  2. 掌握实现接口类的定义要求;
  3. 掌握实现了接口类的使用要求;
  4. 理解程序回调设计模式;
  5. 掌握Comparator接口用法;
  6. 掌握对象浅层拷贝与深层拷贝方法;
  7. 掌握Lambda表达式语法;
  8. 了解内部类的用途及语法要求。

第一部分:总结第六章理论知识

一: 接口:

a. Java为了克股单继承的缺点。Java使用了接口,一个类可以实现一个或多个接口.

b. 在Java中。 接口不是类而是对类的一组需求描述。由常量和一组抽象方法组成.

c. 接口中不包括变量和有具体实现的方法。

d. 接口不能构造接口对象,但可以声明接口变量

e. 自定义接口的声明:     public  interface   接口名

f. 类实现某个接口:  class 类  inplements  接口名

g. 接口可以扩展    public interface  接口1  extends 接口2

h.  int compareTo(T other)

用这个对象与other进行比较,如果这个对象小于other则返回负值,如果相等则返回0,否则返回正值。

    static void sort(Object[ ] a)

对数组a中的元素进行排序。要求数组中的元素必须属于实现了Comparable接口的类,并且元素之间必须是可比较的。

    static int compare(int x,int y)7

如果x<y返回一个一个负整数,如果x和y相等,则返回0,否则返回一个负整数。

    static int compare(double x,double y)1.4

如果x<y返回一个负数,如果x和y相等则返回一个0,否则返回一个负数。

i.  接口与抽象类的区别:
(1)接口不能实现任何方法,而抽象类可以;
(2)类可以实现很多接口,但只有一个父类;
(3)接口不是一个类分级结构中的一部分,无任何联系的类可以实现相同的接口。

二:接口示例:

1. 接口与回调:回调:一种程序设计模式,可以指出某个特定事件发生时应该采取的动作。java.swing包中Timer类,可以使用它在到达给定的时间间隔时触发一个事件。

2. 对象克隆: 当拷贝一个对象变量时,原始变量与拷贝变量引用同一个对象,这样,改变一个变量所引用的对象会对另一个变量产生影响;

如果要创建一个对象新的copy,它的最初状态与original一样,但以后可以各自改变状态,就需要使用0bject类的clone方法。

三:Lambda表达式:

(String first,String second) -> first.length() - second.length()      参数 箭头 表达式

1 .参数类型可推导时.不得要指定类型.如(a)> System.out.println(a)

2. 只有一个参数且类型可推导时。不强制写()

3. 参数指定类型时。必须有括号。

四:内部类:
1. 内部类可以直接访问外部类的成员保括private成员,但是内部类的成员却不能被外部类直接访问。
2. 在内部类对象保存了一个对外部类对象的引用,当内部类的成员方法中访问某一变量时, 如果在该方法和内部类中都未定义过这个变里,内部类中对变里的引用会被传递给外部类对象的引用。
3. 内部类并非只能在类内定义,也可以在程序块内定义局部内部类。例如,在方法中,甚至在for循环体内部。

4. 局部内部类不能用publi c或pr ivate访问修饰符进行声明,它的作用域被限定在声明这个局部类的块中。

匿名内部类
1. 若只创建类的一个对象,则不必为该类命名,这种类称为匿名内部类。
2. 由于匿名类没有类名,所以匿名类不能有构造器,取而代之的是将构造器参数传递给超类的构造器。若匿名内部类实现接口时,则匿名内部类不能有任何构造参数。
3. 如果构造参数的闭圆括号跟一个开花括号,表明正在定义的就是匿名内部类

静态内部类: 静态内部类不持有外部类的引用,只能访问外部类的静态成员变量和方法,而不能访问外部类的非静态成员属性和非静态方法,如果要调用和访问,必须实例化外部类对象。

当静态内部类拥有和外部类同名的成员变量或者方法时,会发生隐藏现象,即默认情况下访问的

是静态内部类的成员。如果要访问外部类的非静态同名成员,不能再使用外部类.this.成员的形式,而是要实例化外部类对象。如果要访问外部类的静态同名成员,可以通过外部类.成员的方式来访问。

与常规内部类不同,静态内部类可以有静态变量和静态方法。可以通过外部类.内部类.静态成员方式来访问。

第二部分

1、实验目的与要求

(1) 掌握接口定义方法;

(2) 掌握实现接口类的定义要求;

(3) 掌握实现了接口类的使用要求;

(4) 掌握程序回调设计模式;

(5) 掌握Comparator接口用法;

(6) 掌握对象浅层拷贝与深层拷贝方法;

(7) 掌握Lambda表达式语法;

(8) 了解内部类的用途及语法要求。

2、实验内容和步骤

实验1 导入第6章示例程序,测试程序并进行代码注释。

测试程序1:

EmployeeSortTest.java

 package interfaces;

 import java.util.*;

 /**
* This program demonstrates the use of the Comparable interface.
* @version 1.30 2004-02-27
* @author Cay Horstmann
*/
public class EmployeeSortTest
{
public static void main(String[] args)
{
Employee[] staff = new Employee[]; staff[] = new Employee("Harry Hacker", );
staff[] = new Employee("Carl Cracker", );
staff[] = new Employee("Tony Tester", ); Arrays.sort(staff);//使用Arrays类的sort方法,对Employee 对象数组进行排序 // 打印出关于 Employee 类的所有信息
for (Employee e : staff)
System.out.println("name=" + e.getName() + ",salary=" + e.getSalary());
}
}

运行结果如下:

a.  Employee.java:

 package interfaces;

 public class Employee implements Comparable<Employee>//Employee类实现泛型Comparable接口
{
private String name;
private double salary; public Employee(String name, double salary)
{
this.name = name;
this.salary = salary;
} public String getName()
{
return name;
} public double getSalary()
{
return salary;
} public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / ;
salary += raise;
} /**
* Compares employees by salary
* @param other another Employee object
* @return a negative value if this employee has a lower salary than
* otherObject, 0 if the salaries are the same, a positive value otherwise
*/
//实现compareTo方法
public int compareTo(Employee other)
{
return Double.compare(salary, other.salary);
}
}

运行结果如下:

b.:

 package interfaces;

 public class Employee implements Comparable<Employee>//Employee类实现泛型Comparable接口
{
private String name;
private double salary; public Employee(String name, double salary)
{
this.name = name;
this.salary = salary;
} public String getName()
{
return name;
} public double getSalary()
{
return salary;
} public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / ;
salary += raise;
} /**
* Compares employees by salary
* @param other another Employee object
* @return a negative value if this employee has a lower salary than
* otherObject, 0 if the salaries are the same, a positive value otherwise
*/
//实现compareTo方法
public int compareTo(Employee other)
{
return name.compareTo(other.name);//按姓名排序
}
}

测试程序2:

编辑、编译、调试以下程序,结合程序运行结果理解程序;

interface  A

{

  double g=9.8;

  void show( );

}

class C implements A

{

  public void show( )

  {System.out.println("g="+g);}

}

 

class InterfaceTest

{

  public static void main(String[ ] args)

  {

       A a=new C( );

       a.show( );

System.out.println("g="+C.g);

  }

}

Interface Test.java:

 package interfaces;
interface A //自定义一个接口A
{
double g=9.8;
void show( );
}
class C implements A//类C 实现接口A
{
public void show( )
{System.out.println("g="+g);}
} class InterfaceTest
{
public static void main(String[ ] args)
{
A a=new C( );
a.show( );
System.out.println("g="+C.g);
}
}

运行结果如下:

测试程序3:

在elipse IDE中调试运行教材223页6-3,结合程序运行结果理解程序;

TimerTest.java:

 package timer;

 /**
@version 1.02 2017-12-14
@author Cay Horstmann
*/ import java.awt.*;
import java.awt.event.*;
import java.time.*;
import javax.swing.*; public class TimerTest
{
public static void main(String[] args)
{
ActionListener listener = new TimePrinter(); // 构造一个listener的计时器
// once every second
Timer t = new Timer(, listener);
t.start(); // 保持程序运行,直到用户选择 "OK"
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit();
}
} class TimePrinter implements ActionListener//类TimePrinter实现接口ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.out.println("At the tone, the time is "
+ Instant.ofEpochMilli(event.getWhen()));
Toolkit.getDefaultToolkit().beep();
}
}

运行结果如下:

测试程序4:

调试运行教材229页-231页程序6-4、6-5,结合程序运行结果理解程序;

CloneTest.java:

 package clone;

 /**
* This program demonstrates cloning.
* @version 1.11 2018-03-16
* @author Cay Horstmann
*/
public class CloneTest
{
public static void main(String[] args) throws CloneNotSupportedException //如果在一个对象上调用clone,如果对象的类没有实现Cloneable的接口。clone方法就会抛出CloneNotSupportedException
{
Employee original = new Employee("John Q. Public", );
original.setHireDay(, , );
//clone方法创建新对象copy,初始状态与Original相同,之后有不同的状态
Employee copy = original.clone();
copy.raiseSalary();
copy.setHireDay(, , );
System.out.println("original=" + original);
System.out.println("copy=" + copy);
}
}

运行结果如下:

Employee.java:

 package clone;

 import java.util.Date;
import java.util.GregorianCalendar; public class Employee implements Cloneable// Employee类 实现Cloneable接口
{
private String name;
private double salary;
private Date hireDay; public Employee(String name, double salary)
{
this.name = name;
this.salary = salary;
hireDay = new Date();
} public Employee clone() throws CloneNotSupportedException //如果在一个对象上调用clone,如果对象的类没有实现Cloneable的接口。clone方法就会抛出CloneNotSupportedException
{
// call Object.clone()
Employee cloned = (Employee) super.clone(); // 克隆可变字段
cloned.hireDay = (Date) hireDay.clone(); return cloned;
} /**
* Set the hire day to a given date.
* @param year the year of the hire day
* @param month the month of the hire day
* @param day the day of the hire day
*/
public void setHireDay(int year, int month, int day)
{
Date newHireDay = new GregorianCalendar(year, month - , day).getTime(); // example of instance field mutation
hireDay.setTime(newHireDay.getTime());
} public void raiseSalary(double byPercent)
{
double raise = salary * byPercent / ;
salary += raise;
} public String toString()
{
return "Employee[name=" + name + ",salary=" + salary + ",hireDay=" + hireDay + "]";
}
}

运行结果如下:

实验2 导入第6章示例程序6-6,学习Lambda表达式用法。

LambdaTest.java:

 package lambda;

 import java.util.*;

 import javax.swing.*;
import javax.swing.Timer; /**
* This program demonstrates the use of lambda expressions.
* @version 1.0 2015-05-12
* @author Cay Horstmann
*/
public class LambdaTest
{
public static void main(String[] args)
{
String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",
"Jupiter", "Saturn", "Uranus", "Neptune" };
System.out.println(Arrays.toString(planets));//toString()方法输出planets
System.out.println("Sorted in dictionary order:");
Arrays.sort(planets);//Arrays.sort方法按字符顺序排序
System.out.println(Arrays.toString(planets));
System.out.println("Sorted by length:");
//Arrays.sort方法按字符串长度排序
Arrays.sort(planets, (first, second) -> first.length() - second.length());
System.out.println(Arrays.toString(planets));
//lambda表达式:(argument)->body
Timer timer = new Timer(, event ->
System.out.println("The time is " + new Date()));
timer.start(); // 程序保持运行,直到用户选择 "OK"
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit();
}
}

运行结果如下:

实验3: 编程练习

l 编制一个程序,将身份证号.txt 中的信息读入到内存中;

l 按姓名字典序输出人员信息;

l 查询最大年龄的人员信息;

l 查询最小年龄人员信息;

l 输入你的年龄,查询身份证号.txt中年龄与你最近人的姓名、身份证号、年龄、性别和出生地;

l 查询人员中是否有你的同乡。

程序代码如下:

 package ID;

 import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Collections; public class Main {
private static ArrayList<Citizen> citizenlist; public static void main(String[] args) {
citizenlist = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
File file = new File("D://身份证号.txt");
try {
FileInputStream fis = new FileInputStream(file);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String temp = null;
while ((temp = in.readLine()) != null) { Scanner linescanner = new Scanner(temp); linescanner.useDelimiter(" ");
String name = linescanner.next();
String id = linescanner.next();
String sex = linescanner.next();
String age = linescanner.next();
String birthplace = linescanner.nextLine();
Citizen citizen = new Citizen();
citizen.setName(name);
citizen.setId(id);
citizen.setSex(sex);
// 将字符串转换成10进制数
int ag = Integer.parseInt(age);
citizen.setage(ag);
citizen.setBirthplace(birthplace);
citizenlist.add(citizen); }
} catch (FileNotFoundException e) {
System.out.println("信息文件找不到");
e.printStackTrace();
} catch (IOException e) {
System.out.println("信息文件读取错误");
e.printStackTrace();
}
boolean isTrue = true;
while (isTrue) { System.out.println("1.按姓名字典序输出人员信息");
System.out.println("2.查询最大年龄的人员信息、查询最小年龄人员信息");
System.out.println("3.查询人员中是否有你的同乡");
System.out.println("4.输入你的年龄,查询文件中年龄与你最近人的姓名、身份证号、年龄、性别和出生地");
System.out.println("5.退出");
int nextInt = scanner.nextInt();
switch (nextInt) {
case :
Collections.sort(citizenlist);
System.out.println(citizenlist.toString());
break;
case :
int max = , min = ;
int m, k1 = , k2 = ;
for (int i = ; i < citizenlist.size(); i++) {
m = citizenlist.get(i).getage();
if (m > max) {
max = m;
k1 = i;
}
if (m < min) {
min = m;
k2 = i;
}
}
System.out.println("年龄最大:" + citizenlist.get(k1));
System.out.println("年龄最小:" + citizenlist.get(k2));
break;
case :
System.out.println("出生地:");
String find = scanner.next();
String place = find.substring(, );
for (int i = ; i < citizenlist.size(); i++) {
if (citizenlist.get(i).getBirthplace().substring(, ).equals(place))
System.out.println("出生地" + citizenlist.get(i));
}
break;
case :
System.out.println("年龄:");
int yourage = scanner.nextInt();
int near = peer(yourage);
int j = yourage - citizenlist.get(near).getage();
System.out.println("" + citizenlist.get(near));
break;
case :
isTrue = false;
System.out.println("程序已退出!");
break;
default:
System.out.println("输入有误");
}
}
} public static int peer(int age) {
int flag = ;
int min = , j = ;
for (int i = ; i < citizenlist.size(); i++) {
j = citizenlist.get(i).getage() - age;
if (j < )
j = -j;
if (j < min) {
min = j;
flag = i;
}
}
return flag;
}
}
 package ID;
public class Citizen implements Comparable<Citizen> { private String name;
private String id;
private String sex;
private int age;
private String birthplace; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getId() {
return id;
} public void setId(String id) {
this.id = id;
} public String getSex() {
return sex;
} public void setSex(String sex) {
this.sex = sex;
} public int getage() {
return age;
} public void setage(int age) {
this.age = age;
} public String getBirthplace() {
return birthplace;
} public void setBirthplace(String birthplace) {
this.birthplace = birthplace;
} public int compareTo(Citizen other) {
return this.name.compareTo(other.getName());
} public String toString() {
return name + "\t" + sex + "\t" + age + "\t" + id + "\t" + birthplace + "\n";
}
}

运行结果如下:

实验4:内部类语法验证实验

实验程序1:

l 编辑、调试运行教材246页-247页程序6-7,结合程序运行结果理解程序;

l 了解内部类的基本用法。

InnerClassTest.java:

 package innerClass;

 import java.awt.*;
import java.awt.event.*;
import java.time.*; import javax.swing.*; /**
* This program demonstrates the use of inner classes.
* @version 1.11 2017-12-14
* @author Cay Horstmann
*/
public class InnerClassTest
{
public static void main(String[] args)
{
TalkingClock clock = new TalkingClock(, true);
clock.start(); // 保持程序运行直到用户选择"OK"
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit();
}
} /**
* A clock that prints the time in regular intervals.
*/
class TalkingClock
{
private int interval;
private boolean beep; /**
* Constructs a talking clock
* @param interval the interval between messages (in milliseconds)
* @param beep true if the clock should beep
*/
public TalkingClock(int interval, boolean beep)
{
this.interval = interval;
this.beep = beep;
} /**
* Starts the clock.
*/
public void start()
{
TimePrinter listener = new TimePrinter();
Timer timer = new Timer(interval, listener);
timer.start();
} public class TimePrinter implements ActionListener//类TimePrinter 实现接口 ActionListener
{
public void actionPerformed(ActionEvent event)
{
System.out.println("At the tone, the time is "
+ Instant.ofEpochMilli(event.getWhen()));
if (beep) Toolkit.getDefaultToolkit().beep();
}
}
}

运行结果如下:

实验程序2:

l 编辑、调试运行教材254页程序6-8,结合程序运行结果理解程序;

l 掌握匿名内部类的用法。

程序代码如下:

 package AnonymouslnnerClass;

 import java.awt.*;
import java.awt.event.*;
import java.time.*; import javax.swing.*; /**
* This program demonstrates anonymous inner classes.
* @version 1.12 2017-12-14
* @author Cay Horstmann
*/
public class AnonymousInnerClassTest
{
public static void main(String[] args)
{
TalkingClock clock = new TalkingClock();
clock.start(, true); // 保持程序运行直到用户选择"OK"
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit();
}
} /**
* A clock that prints the time in regular intervals.
*/
class TalkingClock
{
/**
* Starts the clock.
* @param interval the interval between messages (in milliseconds)
* @param beep true if the clock should beep
*/
public void start(int interval, boolean beep)
{
ActionListener listener = new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.out.println("At the tone, the time is "
+ Instant.ofEpochMilli(event.getWhen()));
if (beep) Toolkit.getDefaultToolkit().beep();
}
};
Timer timer = new Timer(interval, listener);
timer.start();
}
}

运行结果如下:

实验程序3:

l 在elipse IDE中调试运行教材257页-258页程序6-9,结合程序运行结果理解程序;

l 了解静态内部类的用法。

程序代码如下:

 /**
* This program demonstrates the use of static inner classes.
* @version 1.02 2015-05-12
* @author Cay Horstmann
*/
public class StaticInnerClassTest
{
public static void main(String[] args)
{
double[] values = new double[];
for (int i = ; i < values.length; i++)
values[i] = * Math.random();
ArrayAlg.Pair p = ArrayAlg.minmax(values);
System.out.println("min = " + p.getFirst());
System.out.println("max = " + p.getSecond());
}
} class ArrayAlg
{
/**
* A pair of floating-point numbers
*/
public static class Pair //在Pair对象中不需要引用任何其他的对象,所以将这个内部类声明为static
{
private double first;
private double second; /**
* Constructs a pair from two floating-point numbers
* @param f the first number
* @param s the second number
*/
public Pair(double f, double s)
{
first = f;
second = s;
} /**
* Returns the first number of the pair
* @return the first number
*/
public double getFirst()
{
return first;
} /**
* Returns the second number of the pair
* @return the second number
*/
public double getSecond()
{
return second;
}
} /**
* Computes both the minimum and the maximum of an array
* @param values an array of floating-point numbers
* @return a pair whose first element is the minimum and whose second element
* is the maximum
*/
public static Pair minmax(double[] values)//必须使用静态内部类,因为内部类对象是在静态方法中定义的,如果没有将Pair声明为static,编译器会报错,没有可用的隐式ArrayAlg类型对象初始化内部对象
{
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
for (double v : values)
{
if (min > v) min = v;
if (max < v) max = v;
}
return new Pair(min, max); //minmax必须返回返回一个Pair类型的对象
}
}

运行结果如下:

实验总结: 在本次实验中,我学习了接口,接口克服了java单继承的缺点,一个类可以实现一个或多个接口., 接口中不包括变量和有具体实现的方法,接口不能构造接口对象,但可以声明接口变量;

自定义接口的声明:     public  interface   接口名;       类实现某个接口:  class 类  inplements  接口名  ;     接口可以扩展    public interface  接口1  extends 接口,以及接口的一些方法;

Lambda表达式:  (String first,String second) -> first.length() - second.length()      参数 箭头 表达式  , 参数指定类型时,必须有括号, 只有一个参数且类型可推导时,不强制写();还有内部类,匿名内部类和静态内部类。 在实验过程中遇到了很多困难,尤其是编程练习的时候,在参考了其他代码以及问同学的情况下,还算有了一些进步。

20187101035 张玉晶《面向对象程序设计(java)》第八周学习总结的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  10. 20175204 张湲祯 2018-2019-2《Java程序设计》第八周学习总结

    20175204 张湲祯 2018-2019-2<Java程序设计>第八周学习总结 教材学习内容总结 -第十五章泛型与集合框架要点: 一.泛型 1.泛型(Generics)的主要目的是可以 ...

随机推荐

  1. CF798D Mike and distribution

    CF798D Mike and distribution 洛谷评测传送门 题目描述 Mike has always been thinking about the harshness of socia ...

  2. CF343D Water Tree 树链剖分

    问题描述 LG-CF343D 题解 树剖,线段树维护0-1序列 yzhang:用珂朵莉树维护多好 \(\mathrm{Code}\) #include<bits/stdc++.h> usi ...

  3. luoguP2178 [NOI2015]品酒大会(后缀自动机)

    题意 承接上篇题解 考虑两个后缀的\(lcp\)是什么,是将串反着插入后缀自动机后两个前缀(终止节点)的\(lca\)!!!于是可以在parent tree上DP了. 比后缀数组又简单又好写跑的还快. ...

  4. InvalidProgramException

    InvalidProgramException 这tmd是个什么错,我现在都想不起这个exception是怎么触发的了. 后来google了一下,发现是.net 2.0的编译器的bug,和内存或堆栈使 ...

  5. github上计算String相似度好的项目

    项目中包含了杰卡德NGram.cosin夹角.最长公共子序列.边际距离等常用的相似度算法. https://github.com/tdebatty/java-string-similarity

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

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

  7. 项目整合SpringDataRedis

    1:准备工作 先导入redis和jedis依赖,在配置redis-config.properties 和applicationContext-redis.xml (详细配置信息及入门demo见我上一篇 ...

  8. Vue.js 源码分析(三十二) 总结

    第一次写博客,坚持了一个多月时间,Vue源码分析基本分析完了,回过头也看也漏了一些地方,比如双向绑定里的观察者模式,也可以说是订阅者模式,也就是Vue里的Dep.Watcher等这些函数的作用,网上搜 ...

  9. CentOS下安装FreeTDS

    导读 官方网站:http://www.freetds.org 下载地址:http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable ...

  10. CreateDatabase is not supported by the provider

    背景:对于本地数据库如(SQLite\Access) Connection string error: “An exception occurred while initializing the da ...