原创 Item 15 16: In public class, uses accessor methods, not public fields
類是package-private的,是要暴露給客戶端的。x和y是public的,也是要暴露給客戶端的。那麼考慮到向後兼容,這兩個變量將永久暴露給客戶端。 並且,在訪問這兩個變量的前後,不能添加任何操作。getter就可以,比如
原创 Item17 Minimize Mutability
immutable類有個缺點,改變狀態或重新生成一個對象,比如String。BigInteger改變一個bit,就會重新構建一個對象。 BigInteger bigInteger = new BigInteger(new by
原创 Prefer try-with-resources to try-finally
Demo1(Read the second line) finally和try裏如果同時拋出異常,try裏面的異常不會顯示在異常堆棧裏,會影響debug。 static void readFirstLineOfFile(Strin
原创 Item2: Consider a builder when faced with many constructor parameters
easier to read and write than Telescoping Constructor Pattern, and safer than Java Bean Style. demo1: class Bike{
原创 Stream Subgroup
Domain Object public class Dish { public Dish(String name, boolean vegetarian, int calories, Type type) {
原创 Stream Reducing
Dish public class Dish { public Dish(String name, boolean vegetarian, int calories, Type type) { this.n
原创 ubuntu 的包管理
概念: 包管理系統分兩類(本篇講ubuntu): Debian-style(.deb): ubuntu,Debian, Red Hat-style(.rpm):Fedora,CentOS 包(package files) :
原创 Stream multigrouping
initial data public class DataDemo { public enum CaloriesType {LOW, NORMAL, HIGH}; public static List<Dis
原创 命令行操作
idea: ctrl + x; ctrl + y docker: docker-compose -f H:\dh\b2b07\docker-compose.yml up -d appdemo docker-compose -f H
原创 Stream Demo03(reduce, reducing and group)
Prepared Data: public static List<Dish> menu = Arrays.asList( new Dish("pork", false, 800, Dish.Typ
原创 通過源碼安裝package
1.首先下載源碼 2.進入源碼根目錄,在更目錄下執行./configure:生成Makefile文件。 3.接下來的make命令,根據Makefile執行。 4.執行sudo make install。安裝程序會往/usr/loc
原创 sort 命令
例子1: 第5列,以數字的方式,倒序排列。head表示只取前10條 ls -l /usr/bin/ | sort -nrk 5 | head 例子2: 多個列排序 sort --k=1,1 --k=2n a.txt –k=1,1表
原创 微服務 1 springboot
1.介紹microservice 2.介紹springboot 3.創建協作的微服務 4.docker部署微服務 5.添加api描述,openapi/swagger 6.添加持久層 7.reactive microservice 構建 s
原创 微服務2
1.introduction to springboot sping beans, rest apis using springflux, the swagger, Open-Api-based documentation, Sprin
原创 win10下安裝mongoDB
1.下載msi 文件 2.用管理員權限創建以下目錄 cd C: md “\data\db” “\data\log” 3.創建配置文件 C:\Program Files\MongoDB\Server\3.6\mongod.cfg 4