TNG HP I LAB JAVA - NI DUNG
CHI TIT
BÀI LAB 1: Hello World
- T o project Java trên NetBeans.
- Vi t class HelloWorld v i hàm main().ế
- In ra chu i "Hello, world!".
Code:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
BÀI LAB 2: Biến và toán tử
- Khai báo bi n (int, double, String).ế
- Toán t s h c: +, -, *, /, %.
- Toán t logic: &&, ||, !.
- Toán t quan h : >, <, ==, !=.
Ví d : nh p a,b, in t ng, hi u, tích, th ng. ươ
BÀI LAB 3: Cấu trúc điều kiện
- if, if-else, if-else if.
- switch-case.
Ví d : nh p đi m, x p lo i gi i/khá/trung bình. ế
BÀI LAB 4: Vòng lặp
- for, while, do-while.
- In b ng c u ch ng, tính t ng n s , ki m tra s nguyên t . ươ
BÀI LAB 5: Mảng
- Khai báo m ng, nh p d li u.
- Tính t ng, trung bình, tìm max/min.
- S p x p tăng d n, gi m d n. ế
BÀI LAB 6: Hàm (Method)
- Tách ch ng trình thành các hàm.ươ
- Truy n tham s , tr v k t qu . ế
- Ví d : hàm tính giai th a, hàm ki m tra s nguyên t .
BÀI LAB 7: OOP Cơ bản
- Khái ni m class, object, thu c tính, ph ng th c. ươ
- Ví d : class Student (id, name, gpa), method display().
- Qu n lý danh sách sinh viên v i ArrayList.
BÀI LAB 8: Kế thừa
- S d ng t khóa extends.
- Ví d : class Person -> Student, Teacher.
- Ghi đè ph ng th c (override).ươ
BÀI LAB 9: Đóng gói
- Dùng private cho thu c tính.
- Getter/setter đ truy c p d li u.
- Constructor đ kh i t o.
BÀI LAB 10: Đa hình, Abstract, Interface
- Abstract class: Shape (Circle, Rectangle).
- Interface: Movable (Car, Bird).
- Đa hình: cùng method name nh ng x lý khác.ư
BÀI LAB 11: Xử lý ngoại lệ
- try-catch-finally.
- throw, throws.
- Custom exception: InvalidGpaException.
- Ví d : Calculator b t l i chia cho 0.
BÀI LAB 12: File I/O
- Đ c/ghi file văn b n: FileReader, FileWriter.
- Đ c/ghi file nh phân: FileInputStream, FileOutputStream.
- Object serialization v i ObjectOutputStream.
- Ví d : copy file, ghi log.
BÀI LAB 13: Collection Framework
- List: ArrayList, LinkedList.
- Set: HashSet, TreeSet.
- Map: HashMap, TreeMap.
- Duy t b ng for-each, Iterator, forEach lambda.
- S p x p v i Comparable, Comparator. ế
BÀI LAB 14: CSV/JSON + Stream API
- Đ c/ghi CSV (BufferedReader, FileWriter).
- Đ c/ghi JSON v i Gson.
- Stream API: filter, map, collect, groupingBy, averagingDouble, max/min.
- Ví d : tính GPA trung bình theo ngành.
BÀI LAB 15: Stream nâng cao
- Parallel Stream (song song).
- Collector tùy bi n (median, five-number summary).ế
- collectingAndThen, mapping, teeing.
- Grouping l ng nhau, partitioningBy.
- groupByConcurrent cho parallel.
BÀI LAB 16: Concurrency hiện đại
- CompletableFuture: async, thenApply, thenCombine, allOf, anyOf, timeout, retry.
- Virtual Threads (Java 21): thread-per-task nh ,
ExecutorService.newVirtualThreadPerTaskExecutor().
- Structured Concurrency: StructuredTaskScope (ShutdownOnFailure,
ShutdownOnSuccess).
BÀI LAB 17: JDBC & JPA
- JDBC: Connection, Statement, PreparedStatement, ResultSet.
- CRUD: thêm, s a, xóa, tìm.
- JPA/Hibernate: Entity, EntityManager, CRUD, JPQL query.
- Ví d : qu n lý b ng students.
BÀI LAB 18: Spring Boot REST API + JPA
- Spring Boot project v i Spring Web, Spring Data JPA, MySQL Driver.
- Entity Student, Repository, Service, Controller.
- Endpoints CRUD: GET, POST, PUT, DELETE.
- Test b ng Postman.
BÀI LAB 19: Spring Boot + React Fullstack
- Backend: API CRUD Student (Spring Boot + JPA).
- Frontend React: Axios g i API, React Router, form CRUD.
- Hi n th danh sách, thêm/s a/xóa sinh viên.
- K t n i fullstack ch y song song (8080 & 3000).ế
BÀI LAB 20: Spring Boot Security + JWT + React
- Backend: Spring Security + JWT (register, login, me).
- JWT Utils: sinh, xác th c token.
- React: form Login/Register, l u token vào localStorage, Axios interceptor.ư
- Profile route ch vào đ c khi có token h p l . ượ