0%

集合框架

集合框架图


Collection

Collection定义了集合框架的共性功能。

  1. 添加
    add(e);
    addAll(collection);

  2. 删除
    remove(e);
    removeAll(collection);
    clear();

  3. 判断。
    contains(e);
    isEmpty();

  4. 获取
    iterator();
    size();

  5. 获取交集。
    retainAll();

  6. 集合变数组。
    toArray();

閱讀全文 »

String及其他

本篇主要介绍介绍String和其他基本数据类型的包装类型及其常用方法;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class StringDemo
{
public static void main(String[] args)
{
/*
String s1 = "abc";//s1是一个类类型变量, "abc"是一个对象。
//字符串最大特点:一旦被初始化就不可以被改变。

String s2 = new String("abc");

//s1和s2有什么区别?
//s1在内存中有一个对象。
//s2在内存中有两个对象。

System.out.println(s1==s2);
System.out.println(s1.equals(s2));//String类复写了Object类中equals方法,
*/
//该方法用于判断字符串是否相同。

String s = "abcde";
method_1(s);
}
/*
String类是对字符串事物的描述。
该类定义了专门用于操作字符串的方法。
"abc":
*/

public static void method_1(String s)
{
char ch = s.charAt(3);

System.out.println("ch="+ch);
int num = s.codePointAt(3);

System.out.println("num="+num);

String s1 = "qq";
s1 = s1.concat("mm");

System.out.println("s1="+s1);
System.out.println("qq"+"mm");

String a = "opq";
String b = "opq";
System.out.println("a==b:"+(a==b));


}
}
閱讀全文 »

线程通信

线程间通讯:其实就是多个线程在操作同一个资源,但是操作的动作不同。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class ProducerConsumerDemo
{
public static void main(String[] args)
{
Resource r = new Resource();

Producer pro = new Producer(r);
Consumer con = new Consumer(r);

Thread t1 = new Thread(pro);
Thread t2 = new Thread(pro);
Thread t3 = new Thread(con);
Thread t4 = new Thread(con);

t1.start();
t2.start();
t3.start();
t4.start();

}
}
閱讀全文 »

线程

进程和线程的区别

  • 进程:
    是一个正在执行中的程序。
    每一个进程执行都有一个执行顺序。该顺序是一个执行路径,或者叫一个控制元。

  • 线程:就是进程中的一个独立的控制单元。

    线程在控制着进程的执行。

    特点

    一个进程中至少有一个线程。

举例:

  • Java VM 启动的时候会有一个进程java.exe.
    该进程中至少一有个线程负责java程序的执行。而且这个线程运行的代码存在于main方法中。该线程称之为主线程。

  • 扩展:其实更细节说明jvm,jvm启动不止一个线程,还有负责垃圾回收机制的线程。

閱讀全文 »

内部类

内部类简介:
内部类是指在一个外部类的内部再定义一个类。类名不需要和文件夹相同。
内部类可以是静态static的,也可用public,default,protected和private修饰。(而外部顶级类即类名和文件名相同的只能使用public和default)。

注意:内部类是一个编译时的概念,一旦编译成功,就会成为完全不同的两类。对于一个名为outer的外部类和其内部定义的名为inner的内部类。编译完成后出现outer.class和outer$inner.class两类。所以内部类的成员变量/方法名可以和外部类的相同。

閱讀全文 »

最近看微信的跳一跳特别火, 作为一名程序员, 感觉有必要运用一下自己的专(找)业(挂)知(能)识(力), 搞一个高分外挂.
具体流程请参考传送门, 本文只介绍环境搭建过程;

Python

笔者只用过 3.6 其他版本, 推荐使用

突然项目启动时报出以下错误:
百度上的所有答案没能解决, 最终索性重新把mapper文件重新生成了一遍, 结果令人感到意外, 竟然不报错了, 至于原因好像是运行过一个mybatis-gen

1
2
3
4
5
6
7
8
9
10
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bobo.mapper.UserMapper com.bobo.service.impl.UserServiceImpl.userMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bobo.mapper.UserMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.UserMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.UserMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.UserMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.UserMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'avisMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\AvisMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.AvisMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'avisMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\AvisMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.AvisMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [F:\Work\IDEA\bobo\target\classes\com\bobo\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.bobo.mapper.UserMapper.BaseResultMap
Related cause: org.springframework.beans.factory.BeanCreationException: Error