从零基础到独立开发Web应用的实战成长记录与知识体系沉淀
这是一份基于真实学习过程的系统性总结,涵盖从安装JDK到完成SSM整合项目的完整路径,含50+可运行代码示例与7大核心能力训练模型
开始学习HelloWorld.java、理解JVM内存模型基础概念、掌握变量类型与运算符、流程控制语句(if/switch、for/while)、数组定义与操作final关键字、继承与多态、抽象类与接口、内部类、异常处理机制(try-catch-finally)、常用工具类(String/Wrapper/Date/Calendar)、集合框架(List/Set/Map)| 周次 | 核心任务 | 关键能力产出 | 推荐实践项目 |
|---|---|---|---|
| 第1周 | JDK安装与IDE配置、基础语法入门 | 能运行Java程序、理解JVM作用 | 控制台计算器(支持加减乘除) |
| 第2周 | 数组与方法、字符串处理 | 能处理文本数据、实现基础算法 | 学生成绩管理系统(控制台版) |
| 第3周 | 面向对象三大特性 | 能设计类结构、实现封装与复用 | 银行账户管理系统(支持开户/存取款) |
| 第4周 | 异常处理与常用类 | 增强程序健壮性、熟练使用工具类 | 文件内容统计工具(行数/单词数) |
| 第5周 | 集合框架深度学习 | 能选择合适集合类型存储数据 | 通讯录管理系统(支持增删改查) |
| 第6周 | 泛型与集合工具类 | 编写通用代码、使用Collections工具 | 商品库存管理(按条件排序/过滤) |
| 第7周 | 多线程基础与线程同步 | 编写并发程序、解决资源竞争 | 多窗口卖票系统(含线程安全修正) |
| 第8周 | 线程池与Callable接口 | 优化线程管理、获取返回值 | 图片批量下载器(带进度显示) |
| 第9周 | IO流与文件操作 | 实现文件读写、处理文本数据 | 日志文件分析工具(提取错误信息) |
| 第10周 | 网络编程与Socket | 实现C/S通信、理解传输层协议 | 简易聊天室(支持群聊) |
| 第11周 | JDBC与MySQL整合 | 执行SQL语句、处理结果集 | 图书借阅系统(连接MySQL) |
| 第12周 | SSM框架整合项目 | 完成前后端分离开发流程 | 在线笔记系统(支持增删改查) |
ConcurrentModificationException时,应搜索"Java iterate list remove safely",发现正确做法是使用Iterator.remove()或CopyOnWriteArrayListJava是强类型语言,变量必须先声明后使用。基本数据类型共8种,分为四类:
byte(1字节)、short(2字节)、int(4字节)、long(8字节)float(4字节)、double(8字节)char(2字节,UTF-16编码)boolean(仅true/false)特别注意:
int默认整数字面量,long需加L后缀double默认浮点字面量,float需加F后缀char使用单引号,String使用双引号boolean与数值类型相互转换示例代码:
public class DataTypeDemo {
public static void main(String[] args) {
// 整数类型演示
byte b = 127;
short s = 32767;
int i = 2147483647;
long l = 9223372036854775807L;
// 浮点类型演示
float f = 3.1415926f;
double d = 3.141592653589793;
// 字符与字符串
char c = 'A';
String str = "Hello, Java!";
// 布尔类型
boolean flag = true;
// 类型转换(自动与强制)
int num1 = 100;
double num2 = num1; // 自动类型提升
int num3 = (int) 3.14; // 强制类型转换,丢失精度
System.out.println("字节类型范围: " + Byte.MIN_VALUE + " ~ " + Byte.MAX_VALUE);
System.out.println("整数溢出示例: " + (2147483647 + 1)); // 输出-2147483648
}
}
常见易错点:
i++是先使用后自增,++i是先自增后使用&&和||具有短路特性,&和|不短路String拼接结果为String==比较引用类型时比较地址,比较基本类型时比较值经典案例:
public class OperatorDemo {
public static void main(String[] args) {
// 案例1:自增运算符
int i = 5;
int j = i++; // j=5, i=6
int k = ++i; // k=7, i=7
// 案例2:短路逻辑
boolean a = true;
boolean b = false;
System.out.println(a && (b = true)); // 输出true,b保持false(短路)
System.out.println(a & (b = true)); // 输出true,b变为true(不短路)
// 案例3:字符串拼接
System.out.println(1 + 2 + "3"); // 输出"33"(先计算1+2=3,再拼接"3")
System.out.println("1" + 2 + 3); // 输出"123"(从左到右顺序)
// 案例4:比较运算
String s1 = "Java";
String s2 = new String("Java");
System.out.println(s1 == s2); // false(地址不同)
System.out.println(s1.equals(s2)); // true(内容相同)
}
}
建议使用switch的增强特性(JDK7+支持String):
public class SwitchDemo {
public static void main(String[] args) {
String day = "Monday";
switch (day) {
case "Monday" -> System.out.println("工作日开始");
case "Friday" -> System.out.println("周末前最后一天");
case "Saturday", "Sunday" -> System.out.println("周末快乐");
default -> System.out.println("普通工作日");
}
}
}
for-each循环适用于遍历数组和集合:
int[] numbers = {1, 2, 3, 4, 5};
for (int num : numbers) {
System.out.println(num);
}
循环嵌套优化技巧:避免深层嵌套,使用break label跳出多层循环
二维数组初始化方式:
int[][] arr = {{1,2},{3,4,5}};int[][] arr = new int[3][4];常用算法示例:
public class ArrayAlgorithms {
public static void main(String[] args) {
int[] arr = {64, 34, 25, 12, 22, 11, 90};
// 冒泡排序
for (int i = 0; i < arr.length - 1; i++) {
for (int j = 0; j < arr.length - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
// 二分查找(先确保有序)
int target = 22;
int left = 0, right = arr.length - 1;
int index = -1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (arr[mid] == target) {
index = mid;
break;
} else if (arr[mid] < target) {
left = mid + 1;
} else {
right = mid - 1;
}
}
System.out.println("排序后数组: " + Arrays.toString(arr));
System.out.println("22的索引位置: " + index);
}
}
封装原则:
private)getter/setter)标准JavaBean示例:
public class Student {
// 私有属性
private String name;
private int age;
private double score;
// 无参构造
public Student() {}
// 全参构造
public Student(String name, int age, double score) {
this.name = name;
if (age >= 0 && age <= 150) {
this.age = age;
} else {
throw new IllegalArgumentException("年龄必须在0-150之间");
}
if (score >= 0 && score <= 100) {
this.score = score;
} else {
throw new IllegalArgumentException("成绩必须在0-100之间");
}
}
// Getter/Setter方法
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public int getAge() { return age; }
public void setAge(int age) {
if (age >= 0 && age <= 150) {
this.age = age;
}
}
public double getScore() { return score; }
public void setScore(double score) {
if (score >= 0 && score <= 100) {
this.score = score;
}
}
// 业务方法
public String getGrade() {
if (score >= 90) return "A";
else if (score >= 80) return "B";
else if (score >= 70) return "C";
else if (score >= 60) return "D";
else return "F";
}
}
继承要点:
super关键字用于访问父类成员多态实现三要素:
示例代码:
abstract class Animal {
protected String name;
public Animal(String name) {
this.name = name;
}
public abstract void makeSound();
public void sleep() {
System.out.println(name + "正在睡觉");
}
}
class Dog extends Animal {
public Dog(String name) {
super(name);
}
@Override
public void makeSound() {
System.out.println(name + "汪汪叫");
}
}
class Cat extends Animal {
public Cat(String name) {
super(name);
}
@Override
public void makeSound() {
System.out.println(name + "喵喵叫");
}
}
public class PolymorphismDemo {
public static void main(String[] args) {
Animal dog = new Dog("小白");
Animal cat = new Cat("小黑");
dog.makeSound(); // 输出"小白汪汪叫"
cat.makeSound(); // 输出"小黑喵喵叫"
dog.sleep(); // 父类方法,输出"小白正在睡觉"
}
}
接口特性:
default)和静态方法(JDK8+)public static final)函数式接口与Lambda表达式:
@FunctionalInterface
interface Calculator {
int calculate(int a, int b);
}
public class LambdaDemo {
public static void main(String[] args) {
// 传统方式
Calculator add = new Calculator() {
public int calculate(int a, int b) {
return a + b;
}
};
// Lambda表达式
Calculator subtract = (a, b) -> a - b;
Calculator multiply = (a, b) -> a * b;
System.out.println(add.calculate(10, 5)); // 15
System.out.println(subtract.calculate(10, 5)); // 5
System.out.println(multiply.calculate(10, 5)); // 50
// 方法引用
Calculator divide = Math::floorDiv;
System.out.println(divide.calculate(10, 3)); // 3
}
}
核心实现类对比:
| 实现类 | 底层结构 | 线程安全 | 适用场景 |
|---|---|---|---|
ArrayList | 动态数组 | 否 | 频繁查询、尾部插入 |
LinkedList | 双向链表 | 否 | 频繁插入删除 |
Vector | 动态数组 | 是 | 旧版线程安全需求 |
典型用法示例:
import java.util.*;
public class ListDemo {
public static void main(String[] args) {
// ArrayList常用操作
List list = new ArrayList<>();
list.add("Java");
list.add("Python");
list.add(1, "C++"); // 在索引1处插入
// 遍历方式
for (String s : list) {
System.out.println(s);
}
// 删除元素(避免ConcurrentModificationException)
List safeList = new ArrayList<>(list);
safeList.removeIf(s -> s.equals("Python"));
// 查找元素
int index = list.indexOf("Java");
boolean contains = list.contains("C++");
System.out.println("索引位置: " + index);
System.out.println("是否包含: " + contains);
}
}
核心实现类对比:
| 实现类 | 底层结构 | 排序特性 | 线程安全 |
|---|---|---|---|
HashSet | 哈希表 | 无序 | 否 |
LinkedHashSet | 哈希表+链表 | 插入顺序 | 否 |
TreeSet | 红黑树 | 自然排序/自定义排序 | 否 |
去重原理与自定义比较:
class Person implements Comparable{ String name; int age; public Person(String name, int age) { this.name = name; this.age = age; } @Override public int compareTo(Person other) { // 先按年龄升序,再按姓名字典序 int ageCompare = Integer.compare(this.age, other.age); return ageCompare != 0 ? ageCompare : this.name.compareTo(other.name); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; return age == person.age && Objects.equals(name, person.name); } @Override public int hashCode() { return Objects.hash(name, age); } } public class SetDemo { public static void main(String[] args) { Set set = new HashSet<>(); set.add(new Person("张三", 25)); set.add(new Person("李四", 30)); set.add(new Person("张三", 25)); // 不会重复添加 System.out.println("集合大小: " + set.size()); // 输出2 } }
核心实现类对比:
| 实现类 | 线程安全 | 允许null键 | 允许null值 | 适用场景 |
|---|---|---|---|---|
HashMap | 否 | 是(最多一个) | 是 | 通用键值对存储 |
LinkedHashMap | 否 | 是 | 是 | 需要插入顺序 |
TreeMap | 否 | 否 | 是 | 按键排序 |
Hashtable | 是 | 否 | 否 | 旧版线程安全 |
常用操作示例:
import java.util.*;
public class MapDemo {
public static void main(String[] args) {
Map map = new HashMap<>();
map.put("Java", 100);
map.put("Python", 95);
map.put("C++", 88);
// 遍历方式1:entrySet
for (Map.Entry entry : map.entrySet()) {
System.out.println(entry.getKey() + " -> " + entry.getValue());
}
// 遍历方式2:keySet
for (String key : map.keySet()) {
System.out.println("键: " + key + ", 值: " + map.get(key));
}
// 计算最大值对应的键
String maxKey = Collections.max(map.entrySet(),
Map.Entry.comparingByValue()).getKey();
System.out.println("最高分语言: " + maxKey);
}
}
核心实现类对比:
| 实现类 | 线程安全 | 特性 | 适用场景 |
|---|---|---|---|
LinkedList | 否 | 双端队列 | 通用队列操作 |
ArrayDeque | 否 | 基于数组的双端队列 | 高性能队列 |
PriorityQueue | 否 | 优先级堆 | 任务调度 |
ConcurrentLinkedQueue | 是 | 无界并发队列 | 多线程生产者-消费者 |
优先级队列示例:
import java.util.*;
public class QueueDemo {
public static void main(String[] args) {
PriorityQueue pq = new PriorityQueue<>(Collections.reverseOrder());
pq.add(30);
pq.add(10);
pq.add(20);
System.out.println("最高优先级: " + pq.peek()); // 输出30
System.out.println("出队: " + pq.poll()); // 输出30
System.out.println("当前大小: " + pq.size()); // 输出2
}
}
核心操作分类:
filter、map、sorted、distinctcollect、forEach、reduce、count综合案例:学生信息处理:
import java.util.*;
import java.util.stream.Collectors;
class Student {
String name;
int score;
public Student(String name, int score) {
this.name = name;
this.score = score;
}
// Getter方法
public String getName() { return name; }
public int getScore() { return score; }
}
public class StreamDemo {
public static void main(String[] args) {
List students = Arrays.asList(
new Student("张三", 85),
new Student("李四", 92),
new Student("王五", 78),
new Student("赵六", 95)
);
// 1. 筛选分数>80的学生
List highScores = students.stream()
.filter(s -> s.getScore() > 80)
.collect(Collectors.toList());
// 2. 提取姓名并转换为大写
List names = students.stream()
.map(Student::getName)
.map(String::toUpperCase)
.collect(Collectors.toList());
// 3. 按分数降序排序
students.stream()
.sorted(Comparator.comparing(Student::getScore).reversed())
.forEach(s -> System.out.println(s.getName() + ": " + s.getScore()));
// 4. 计算平均分
double avgScore = students.stream()
.mapToInt(Student::getScore)
.average()
.orElse(0.0);
System.out.println("平均分: " + avgScore);
}
}
Map系列(常用HashMap)TreeSet/TreeMapVector/Hashtable/ConcurrentHashMapLinkedListArrayList(默认选择)三种创建方式:
线程池使用示例:
import java.util.concurrent.*;
public class ThreadPoolDemo {
public static void main(String[] args) throws Exception {
// 创建固定大小线程池
ExecutorService pool = Executors.newFixedThreadPool(3);
// 提交Callable任务
Future future = pool.submit(() -> {
System.out.println("任务执行中: " + Thread.currentThread().getName());
return 42;
});
// 获取结果(阻塞等待)
Integer result = future.get();
System.out.println("任务结果: " + result);
// 关闭线程池
pool.shutdown();
}
}
同步方案对比:
| 方案 | 实现方式 | 适用场景 | 优缺点 |
|---|---|---|---|
synchronized | 关键字修饰方法/代码块 | 简单同步需求 | 简单但不够灵活 |
ReentrantLock | 显式加锁解锁 | 需要锁特性扩展 | 灵活但需手动释放 |
volatile | 变量修饰符 | 状态标记 | 轻量但不保证原子性 |
Atomic类 | 原子操作类 | 计数器等简单场景 | 高性能但适用范围有限 |
生产者-消费者模式实现:
import java.util.concurrent.*;
public class ProducerConsumerDemo {
private static final int CAPACITY = 5;
private static final BlockingQueue queue = new ArrayBlockingQueue<>(CAPACITY);
public static void main(String[] args) {
// 生产者线程
Thread producer = new Thread(() -> {
try {
for (int i = 0; i < 10; i++) {
queue.put(i);
System.out.println("生产: " + i);
Thread.sleep(500);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
// 消费者线程
Thread consumer = new Thread(() -> {
try {
while (true) {
Integer value = queue.take();
System.out.println("消费: " + value);
Thread.sleep(800);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
});
producer.start();
consumer.start();
}
}
经典生产者-消费者(wait/notify版本):
class SharedBuffer {
private int data;
private boolean available = false;
public synchronized void produce(int value) throws InterruptedException {
while (available) {
wait(); // 等待消费者消费
}
data = value;
available = true;
notifyAll(); // 通知消费者
System.out.println("生产: " + value);
}
public synchronized int consume() throws InterruptedException {
while (!available) {
wait(); // 等待生产者生产
}
available = false;
notifyAll(); // 通知生产者
System.out.println("消费: " + data);
return data;
}
}
传统IO方式:
import java.io.*;
import java.util.*;
public class FileIODemo {
public static void main(String[] args) {
String filePath = "students.txt";
// 写入文件
try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath))) {
writer.write("姓名,年龄,成绩");
writer.newLine();
writer.write("张三,20,85.5");
writer.newLine();
writer.write("李四,21,92.0");
} catch (IOException e) {
e.printStackTrace();
}
// 读取文件
try (BufferedReader reader = new BufferedReader(new FileReader(filePath))) {
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
实现Serializable接口:
import java.io.*;
import java.util.*;
class Student implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private int age;
private double score;
// 构造方法、Getter/Setter省略...
}
public class SerializationDemo {
public static void main(String[] args) {
Student student = new Student("王五", 22, 88.5);
// 序列化
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("student.ser"))) {
oos.writeObject(student);
System.out.println("序列化完成");
} catch (IOException e) {
e.printStackTrace();
}
// 反序列化
try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream("student.ser"))) {
Student deserialized = (Student) ois.readObject();
System.out.println("反序列化结果: " + deserialized.getName());
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
}
Path与Files操作:
import java.nio.file.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
public class NIODemo {
public static void main(String[] args) {
Path path = Paths.get("data.txt");
// 写入文本
try {
Files.writeString(path, "Hello, NIO!", StandardCharsets.UTF_8);
} catch (IOException e) {
e.printStackTrace();
}
// 读取文本
try {
String content = Files.readString(path, StandardCharsets.UTF_8);
System.out.println("文件内容: " + content);
} catch (IOException e) {
e.printStackTrace();
}
// 列出目录文件
try (DirectoryStream stream = Files.newDirectoryStream(Paths.get("."))) {
for (Path file : stream) {
System.out.println(file.getFileName());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
服务器端:
import java.io.*;
import java.net.*;
public class TCPServer {
public static void main(String[] args) {
try (ServerSocket serverSocket = new ServerSocket(8080)) {
System.out.println("服务器启动,等待连接...");
Socket socket = serverSocket.accept();
// 获取输入流(读取客户端数据)
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String message = in.readLine();
System.out.println("收到客户端消息: " + message);
// 获取输出流(发送响应)
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.println("服务器已收到: " + message);
socket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
客户端:
import java.io.*;
import java.net.*;
public class TCPClient {
public static void main(String[] args) {
try (Socket socket = new Socket("localhost", 8080)) {
// 获取输出流(发送数据)
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
out.println("Hello, Server!");
// 获取输入流(接收响应)
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String response = in.readLine();
System.out.println("服务器响应: " + response);
} catch (IOException e) {
e.printStackTrace();
}
}
}
发送端:
import java.net.*;
public class UDPClient {
public static void main(String[] args) throws Exception {
DatagramSocket socket = new DatagramSocket();
InetAddress address = InetAddress.getByName("localhost");
byte[] data = "Hello, UDP!".getBytes();
DatagramPacket packet = new DatagramPacket(data, data.length, address, 9000);
socket.send(packet);
socket.close();
}
}
接收端:
import java.net.*;
public class UDPServer {
public static void main(String[] args) throws Exception {
DatagramSocket socket = new DatagramSocket(9000);
byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet);
String message = new String(packet.getData(), 0, packet.getLength());
System.out.println("收到UDP消息: " + message);
socket.close();
}
}
完整示例:
import java.sql.*;
public class JDBCDemo {
public static void main(String[] args) {
String url = "jdbc:mysql://localhost:3306/school?useSSL=false&serverTimezone=UTC";
String user = "root";
String password = "123456";
// 1. 加载驱动(JDBC4+可省略)
// Class.forName("com.mysql.cj.jdbc.Driver");
try (Connection conn = DriverManager.getConnection(url, user, password)) {
// 2. 创建Statement
Statement stmt = conn.createStatement();
// 3. 执行查询
String sql = "SELECT id, name, score FROM students WHERE score > 80";
ResultSet rs = stmt.executeQuery(sql);
// 4. 处理结果
while (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
double score = rs.getDouble("score");
System.out.println(id + " - " + name + ": " + score);
}
// 5. 执行更新
String updateSql = "UPDATE students SET score = score + 5 WHERE id = 1";
int rows = stmt.executeUpdate(updateSql);
System.out.println("更新行数: " + rows);
} catch (SQLException e) {
e.printStackTrace();
}
}
}
参数化查询示例:
String sql = "SELECT * FROM students WHERE name = ? AND score > ?";
try (PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(1, "张三");
pstmt.setDouble(2, 80);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getInt("id") + " - " + rs.getString("name"));
}
}
核心方法:
init():初始化(仅调用一次)service():处理请求(每次请求调用)destroy():销毁(服务器关闭时调用)简单Servlet示例:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.setContentType("text/html;charset=UTF-8");
PrintWriter out = resp.getWriter();
out.println("Hello, Servlet!
");
out.println("当前时间: " + new java.util.Date() + "
");
}
}
三种脚本元素:
<% %>:Java代码片段<%= %>:表达式输出<%! %>:声明变量/方法JSP页面示例:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Hello JSP</title></head>
<body>
<h1>欢迎访问JSP页面</h1>
<%
int count = 0;
for (int i = 1; i <= 5; i++) {
count += i;
}
%>
<p>1到5的和是: <%= count %></p>
<p>当前服务器时间: <%= new java.util.Date() %></p>
</body>
</html>
XML映射文件示例:
<select id="selectStudents" parameterType="map" resultType="Student">
SELECT * FROM students
<where>
<if test="name != null and name != ''">
AND name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="minScore != null">
AND score > #{minScore}
</if>
</where>
</select>
XML配置方式:
<bean id="studentService" class="com.example.service.StudentService">
<property name="studentDao" ref="studentDao"/>
</bean>
<bean id="studentDao" class="com.example.dao.StudentDaoImpl"/>
注解方式:
@Service
public class StudentService {
@Autowired
private StudentDao studentDao;
}
| 表名 | 字段说明 | 关键字段 |
|---|---|---|
| users | 用户表 | id, username, password, email |
| notes | 笔记表 | id, user_id, title, content, create_time |
| tags | 标签表 | id, name |
| note_tags | 笔记-标签关联表 | note_id, tag_id |
-- 多表联查:获取用户及其笔记
SELECT u.username, n.title, n.create_time
FROM users u
JOIN notes n ON u.id = n.user_id
WHERE u.username = #{username}
-- 笔记搜索(模糊匹配)
SELECT * FROM notes
WHERE title LIKE CONCAT('%', #{keyword}, '%')
OR content LIKE CONCAT('%', #{keyword}, '%')
ORDER BY create_time DESC
问题表现:学习三个月仍停留在HelloWorld阶段
正确做法:采用"最小可行产品"(MVP)方法,边学边做,每个阶段产出可运行的小项目
实践建议:第1周完成控制台计算器,第2周完成成绩管理系统,第3周完成银行账户系统
问题表现:遇到新类就查文档,效率低下
正确做法:理解设计模式与类层次结构,掌握常用类的核心方法
记忆技巧:
• List:增删改查 → add/remove/set/get
• Map:键值对操作 → put/get/remove/containsKey
• String:不可变性 → 通过substring/replace生成新对象
问题表现:程序崩溃后无法定位问题
正确做法:
• 关键操作必须try-catch
• 记录异常日志(使用Logger)
• 优先处理具体异常类型
示例:try { ... } catch (FileNotFoundException e) { ... } catch (IOException e) { ... }
问题表现:简单功能使用复杂框架
正确做法:
• 控制台程序用基础IO即可
• 网络通信先用Socket再学Netty
• 数据库操作先掌握JDBC再学MyBatis
问题表现:教程都能看懂,自己写就出错
正确做法:每个知识点立即动手实现
建议方法:
• 看完5分钟内开始编码
• 使用IDEA的"Refactor → Rename"功能理解变量作用域
• 用Debug模式单步执行理解程序流程
答案:面向对象编程(第3-4周)和集合框架(第5-6周)是两大关键卡点。
原因分析:
• 继承与多态抽象概念难以理解
• 集合API种类繁多,选择困难
解决方案:
• 画UML类图理解关系
• 制作"集合选择决策树"海报贴在电脑旁
• 通过实际项目(如通讯录系统)巩固知识
答案:达到初级Java开发工程师入门水平,能够:
• 独立开发控制台应用
• 理解并修改简单Web应用
• 完成SSM框架的CRUD操作
• 理解MVC分层架构
后续提升方向:
• 深入学习Spring Boot微服务
• 掌握Spring Cloud分布式架构
• 学习Redis缓存与消息队列
答案:高原期通常出现在第6-8周,表现为学习效率下降、动力不足。
应对策略:
• 项目驱动法:选择一个感兴趣的小项目(如天气预报应用)持续开发
• 结对编程:与学习伙伴互相review代码
• 输出倒逼输入:写技术博客记录学习过程
• 阶段性奖励:完成阶段目标后给自己小奖励
答案:
• 官方文档:Oracle Java SE Documentation
• 在线课程:慕课网《Java零基础入门》、极客时间《Java核心技术30讲》
• 开源项目:GitHub上"good-first-issue"标签的项目
• 书籍:《Java核心技术 卷I》、《Effective Java》
• 社区:Stack Overflow、CSDN、掘金