本博客的实现根据后面这篇文章而搭建:传送门
新手入门看这篇。传送门
Johnhoo‘s Blog
在过往的Java项目中,充斥着太多不友好的代码:POJO的getter/setter/toString;异常处理;I/O流的关闭操作等等,这些样板代码既没有技术含量,又影响着代码的美观,Lombok应运而生。
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>x.x.x</version><!--1.16.18-->
<scope>provided</scope>
</dependency>
Lombok的scope=provided,说明它只在编译阶段生效,不需要打入包中。事实正是如此,Lombok在编译期将带Lombok注解的Java文件正确编译为完整的Class文件。
POJO常用注解:
其他重要注解:
通过相邻两个元素的比较,把大的数放到后面,一轮过后最大的数“浮”到最后面。这样“浮”到最后的元素就是已经排好序的。然后通过每一轮把剩余的序列“浮”出最大的数到最后面,最终得到排好的序列。
void bubbleSort(int[] a){
int length = a.length;
int temp;
int flag; //交换标志(0代表没有交换过,1代表交换过)
for(int i = 0; i < length; i++){ //外层循环控制轮数,总轮数为length
flag = 0; //置为0
for(int j = 0; j < length - i - 1; j++){ //内层循环为当前第i轮数所需要比较的次数。为什么-1:每多一轮则减少一次比较次数。
if(a[j] > a[j+1]){
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
flag = 1; //置为1
}
if(flag == 0) //如果没有交换过,则代表序列已经有序,不必再比较。
break;
}
}
最好的情况:当序列是顺序序列时,元素不需要移动,所以最好的时间复杂度为O(n);
最坏的情况:当序列是逆序序列时,元素每比较一次都需要移动一次,最坏的时间复杂度为O(n²);
所以平均时间复杂度为O(n²)。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.