Java: Debugging and Packaging Applications
Types of Errors
Compile-time Errors: 语法错误导致的错误,编译器能检测到
Run-time Errors: 逻辑错误等,用 Debugger 来检测
Debugging
在命令行前点击增加断点(或 Run -> ViewBreakpoints 或 快捷键 command + shift + F8)
Debug 运行(Control + D)
调用栈
Packaging构建一个 Java 程序后,若想分享给别人使用, 需要将代码打包进一个 jar 文件中,jar 是 Java Archive 的简称,他是一个包文件形式,包含用于分享的所有代码。
构建方式:
File -> Project Structure -> Artifacts -> + -> JAR -> From modules with dependencies
选择 Main Class
OK and OK
Build -> Build Artifacts
选择 Build,Rebuild 或者 Clean,第一次选择 Build
在代码左侧 ...
Java: Clean Coding
Creating Methods1234567891011public class Main { public static void main(String[] args) { String message = greetUser("Lucas", "YE"); System.out.println(message); } public static String greetUser(String firstName, String lastName){ return "Hello " + firstName + " " + lastName; }}
Extracting Methords改变代码的结构却不改变它的行为
12345678910111213141516171819202122232425262728293031323334353637383940public clas ...
Java: Control Flow
Comparison Operators
>
\<
\=
>=
\<=
Logical Operators
&&
||
!
Conditional StatementsIf12345678910111213public class Main { public static void main(String[] args) { int temp = 32; if (temp > 30) { System.out.println("Il fait chaud!"); } else if (temp >20) { System.out.println("Il fait bon!"); } else { System.out.println("Il fait froid!"); } ...
Java: Types
Primitive types
Primitive types: for storing simple values
Refrences: for storing complex objects
Type
Bytes
Range
byte
1
[-128, 127]
short
2
[-32k, 32k]
int
4
[-2B, 2B]
long
8
float
4
double
8
char
2
A, B, C, …
boolean
1
true / false
Reference types
Primitive types: numbers, characters, booleans
Refrences: data, mail message
12345678public class Main { public static void main(String[] args) { byte age = 21; Date now = new Date(); ...
Deep Learning: Diffusion Models - Part 1
IntroDiffusion models are unsupervised probabilistic generative models inspired by non-equilibrium thermodynamics. They have 2 major processes:
Forward diffusion process: Adding noise to data until the result is no different to random noise.
Reverse diffusion process: Learning to reverse the diffusion process to reconstruct the original data from the noise obtained from forward diffusion process.
Forward diffusion processGiven an image, which we call x_0, the forward diffusion process is in w ...