前段时间学习沉淀了三个月,终于面试通过了阿里,原本就一直想着将自己积累的知识分享出去,这段时间由于公司的项目基本稳定,新项目的产品需求还没完全确定下来,所以就趁着这段时间整理了思维导图,分享下曾经的学习路线,以便有需要的人学习
这次主要整理的有:
并发编程
kafka
spring
mybatis

并发编程:
并发基础
线程池
原子操作
内存模型
线程通信
其他
锁
并发集合
并发工具类
synchronized

Kafka:
kafka是什么
kafka特点
kafka历史
安装
使用
kafka常用场景
常见消息队列
架构

jvm:
jvm调优
内存相关
内存结构
对象
class文件结构
垃圾收集
类加载机制

spring:
spring测试
生命周期
IOC
AOP

mybatis:
查询缓存
高级映射
应用知识结构图

我的学习笔记对于这些知识点都有详细的思维学习路线,除上述这几个专题的思维学习路线,还整理了有spring原理,微服务,Java集合等等专题的详细笔记。和大厂的面试整体以及解析
java核心知识点pdf:

大厂面试真题:

简易图书管理系统
- public class Book {
- }
- public class Book {
-
- private String name; //书名
- private String author; //作者
- private int price; //价格
- private String type; //类型
- private boolean isBorrowed;//是否被借出 默认false
实例化对象,设置几个属性,因为字段是private修饰的就给每属性get set方法
在加个构造和toString方法
- //构造
- public Book(String name, String author, int price, String type) {
-
- this.name = name;
- this.author = author;
- this.price = price;
- this.type = type;
- }
- //get+set
- public String getName() {
-
- return name;
- }
-
- public void setName(String name) {
-
- this.name = name;
- }
-
- public String getAuthor() {
-
- return author;
- }
-
- public void setAuthor(String author) {
-
- this.author = author;
- }
-
- public int getPrice() {
-
- return price;
- }
-
- public void setPrice(int price) {
-
- this.price = price;
- }
-
- public String getType() {
-
- return type;
- }
-
- public void setType(String type) {
-
- this.type = type;
- }
-
- public boolean isBorrowed() {
-
- return isBorrowed;
- }
-
- public void setBorrowed(boolean borrowed) {
-
- isBorrowed = borrowed;
- }
- //toString
- @Override
- public String toString() {
-
- return "Book{" +
- "name='" + name + '\'' +
- ", author='" + author + '\'' +
- ", price=" + price +
- ", type='" + type + '\'' +
- ((isBorrowed==true)?"已经借出":"未借出") +
- '}';
- }
- public class BookList{
- }
- //对多放十本
- private Book[] books = new Book[3];
- private int usedSize ; //实时记录 目前有几本书
- public BookList() {
-
- books[0] = new Book("西游记","吴承恩",10,"小说");
- books[1] = new Book("三国演义","施耐庵",11,"小说");
- books[2] = new Book("红楼梦","曹雪芹",12,"小说");
- usedSize = 3;
- }
- //拿出pos处的书
- public Book getBook(int pos){
-
- return books[pos];
- }
- // 给pos下标放一本书
- public void setBook(int pos, Book book){
-
- books[pos] = book;
- }
- //获取实时书本数,用于修改
- public int setUesSize(int size){
-
- return (usedSize = size);
- }
- public int getUesSize(){
-
- return this.usedSize;
- }
- public class AdmainUser extends User{
- }
- //提供构造方法帮助父类构造
- public AdmainUser(String name) {
-
- super(name);
- //在new管理人员这个对象时,就把这些功能一并写入
- this.iOperations = new IOperation[]{
-
- new ExitOperation(),//0
- new FindOperation(),
- new AddOperation(),
- new DelOperation(),
- new DisplayOperation()
- };
- //设置一个开始菜单
- public int menu (){
-
- System.out.println("hello"+this.name+"欢迎使用BMS!");
- System.out.println("1.查找图书");
- System.out.println("2.增添图书");
- System.out.println("3.删除图书");
- System.out.println("4.显示图书");
- System.out.println("0.退出BNS");
- Scanner scanner = new Scanner(System.in);
- return scanner.nextInt();
- }
- public class NormalUser extends User{
- }
- //设置一个开始菜单
- public int menu (){
-
- System.out.println("hello"+this.name+"欢迎使用BMS!");
-
- System.out.println("1.查找图书");
- System.out.println("2.借阅图书");
- System.out.println("3.归还图书");
- System.out.println("0.退出BNS");
- Scanner scanner = new Scanner(System.in);
- return scanner.nextInt();
- }
- //提供构造方法帮助父类构造
- public NormalUser(String name) {
-
- super(name);
- //在new一般人员这个对象时,就把这些功能一并写入
- this.iOperations = new IOperation[]{
-
- new ExitOperation(),//0
- new FindOperation(),
- new BorrowOperation(),
- new ReturnOperation()
- };
- }
身份不同,拥有的功能不一样
| 管理员 | 一般用户 |
|---|---|
| 1.查找图书 | 1.查找图书 |
| 2.增添图书 | 2.借阅图书 |
| 3.删除图书 | 3.归还图书 |
| 4.显示图书 | |
| 0.退出BNS | 0.退出BNS |
- public interface IOperation {
-
- //实现功能
- public abstract void work(BookList bookList);
- }
Tips:
要先输入字符串String,再输入整数int!
先输入整数再输字符串的话回车会被读进去
- package operation;
-
- import book.Book;
- import book.BookList;
-
- import java.util.Scanner;
-
- public class AddOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("添加图书!");
-
- Scanner scanner = new Scanner(System.in);
- System.out.println("请输入图书的名字");
- String name = scanner.nextLine();
-
- System.out.println("请输入图书的作者");
- String author = scanner.nextLine();
-
- System.out.println("请输入图书的类型");
- String type = scanner.nextLine();
-
- System.out.println("请输入图书的价格");
- int price = scanner.nextInt();
-
- Book newbook = new Book(name,author,price,type);
- bookList.setBook(bookList.getUesSize(),newbook);
- bookList.setUesSize(bookList.getUesSize()+1); //更新数量
-
- System.out.println("新增书记成功!");
- }
- }
- package operation;
-
- import book.Book;
- import book.BookList;
-
- import java.util.Scanner;
-
- public class BorrowOperation implements IOperation{
-
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("借出图书!");
-
- System.out.print("请输入借阅图书的名字:");
- int currentSize = bookList.getUesSize();
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- for (int i = 0 ; i < currentSize; i++) {
-
- Book book = bookList.getBook(i);
- if (book.getName().equals(name)) {
-
- System.out.println("找到了!");
- book.setBorrowed(true); //改状态
- System.out.println("借阅成功!");
- return;
- }
- }
- System.out.println("没有这本书!");
- System.out.println();
- }
- }
- package operation;
-
- import book.Book;
- import book.BookList;
-
- import java.util.Scanner;
-
- /**
- *覆盖
- */
- public class DelOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("删除图书!");
- System.out.print("请输入图书的名字:");
- int currentSize = bookList.getUesSize();
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- int index = -1;//存下标
- int i = 0;
- for ( ; i < currentSize; i++) {
-
- Book book = bookList.getBook(i);
- if (book.getName().equals(name)) {
-
- System.out.println("找到了!");
- index = i;
- System.out.println(book);
- System.out.println();
- }
- }
- if (i >= currentSize) {
-
- System.out.println("找不到此书");
- return;
- }
- //直接覆盖
- for (int j = index; j < currentSize-1; i++) {
-
- bookList.setBook(j,bookList.getBook(j +1));
- }
- bookList.setUesSize(bookList.getUesSize()-1); //更新数量
- bookList.setBook(currentSize-1,null); //置为空 相当于free
- System.out.println("删除成功!");
- System.out.println();
- }
- }
- package operation;
-
- import book.BookList;
-
- public class DisplayOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("显示图书!");
- int currentSize = bookList.getUesSize();
- for (int i = 0; i < currentSize; i++) {
-
- System.out.println(bookList.getBook(i));
- }
- System.out.println();
- }
- }
- package operation;
-
- import book.Book;
- import book.BookList;
-
- import java.util.Scanner;
-
- public class ReturnOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("归还图书!");
-
- System.out.print("请输入归还图书的名字:");
- int currentSize = bookList.getUesSize();
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- for (int i = 0 ; i < currentSize; i++) {
-
- Book book = bookList.getBook(i);
- if (book.getName().equals(name)) {
-
- System.out.println("找到了!");
- book.setBorrowed(true); //改状态
- System.out.println("归还成功!");
- return;
- }
- }
- System.out.println("没有这本书!");
- System.out.println();
- }
- }
- package operation;
-
- import book.Book;
- import book.BookList;
-
- import java.util.Scanner;
-
- public class FindOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.print("请输入图书的名字:");
- int currentSize = bookList.getUesSize();
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- for (int i = 0 ; i < currentSize; i++) {
-
- Book book = bookList.getBook(i);
- if (book.getName().equals(name)) {
-
- System.out.println("找到了!");
- System.out.println(book);
- System.out.println();
- return;
- }
- }
- System.out.println("没有这本书!");
- System.out.println();
- }
- }
- package operation;
-
- import book.BookList;
-
- public class ExitOperation implements IOperation{
-
- @Override
- public void work(BookList bookList) {
-
- System.out.println("退出系统!");
- System.exit(0); // 状态码 零代表正常结束,负数异常结束
- }
- }
整理所有功能
- import book.Book;
- import book.BookList;
- import user.AdmainUser;
- import user.NormalUser;
- import user.User;
-
- import java.util.Scanner;
-
- //登录
- public class Main {
-
- public static User login(){
-
- System.out.println("请输入你的姓名:");
- Scanner scanner = new Scanner(System.in);
- String name = scanner.nextLine();
- System.out.println("请输入你的身份: 1-->管理员,2-->普通用户");
- int choise = scanner.nextInt();
- if(choise == 1){
-
- return new AdmainUser(name);
- }else {
-
- return new NormalUser(name);
- }
- }
- public static void main(String[] args) {
-
- //整合!
- BookList bookList = new BookList();//准备图书
- //登录,
- User user = login();
- while(true) {
-
- int choise = user.menu();//父类的引用想访问子类的方法,此方法必须为抽象方法,动态绑定
- user.doOperator(choise, bookList);
- }
- }
- }