一个最简单的程序
/**
define a class, class is the container of logic process.
*/
public class FirstSimple {
//this is the entrince of application
public static void main(String[] args) {
//print content to terminal
System.out.println("We will not use 'Hello, World'");
}
}
数据类型

字符串
字符串是在程序中需要处理的最常见的数据类型,java中用String来标识字符串,String是不可变对象,内部基于char[]数组实现,并且提供了大量用于操作字符串的api。
字符串在进行拼接的时候一般会使用‘+’或StringBuilder,但‘+’有可能会产生大量的中间对象,所以并不推荐使用。
判空操作:
str == null;
"".equals(str);
public boolean isEmpty() {
return str == null || "".equals(str);
}
变量
java中的变量有两种,即变量和常量,声明方式为 【类型】变量名 = 取值;如果被final修饰,变量就变成了不可变的常量。
运算符
算数运算符
+、-、*、/、%
关系运算法
&、&&、|、||、==、!=
三目运算符
condition ? exp1 : exp2;
位运算符
&、^、|、~
流程控制
if..else if..else
while、do..while
for
foreach
break、continue
switch..case
5513

被折叠的 条评论
为什么被折叠?



