① 整数间的运算规则
@Test
public void test01(){
// 1. boolean 不可运算;
boolean b11 = false; boolean b12 = true;
System.out.println((b11 || b12) == true);
// 2. short, char 型会向上转型为 int;
short s1 = 12;
char c1 = 'A'; int i = c1++%6;
int i11 = s1 + c1;
// 3. 单精度浮点数表示整数时不用加 f,表示小时时需要加 f
float f = 10.05f;
float f1 = 10;
// 4. 双精度double表示小数可加 d 也可不加
double a = 12.5d;
double a1 = 12.50;
// 5. float 运算会转化为 double
float b = (float) ((a + 5) / 2.1f);
double d1 = (a + 5) / 2.1f;
}
② string.concat(), string.replace() 返回新对象
@Test
public void test02(){
String s = "we are";
s.concat("family");
s.replace("we", "We");
System.out.println(s);// we are
}
// 产生上述结果的原因:未更新引用值
③ mkdir 命令
Linux创建目录和文件 mkdir、touch、cp、rm、mv 和 ln命令_奋斗的蜗牛灬的博客-优快云博客_linux创建目录的命令
选项 | 说明 |
---|---|
-p | 未创建父目录/上层目录时,先创建上层目录 |
-m | 设置权限模式 |
-v | 每次创建目录,显示详细信息 |
-Z | 设置目录的安全环境 CTX |
④ Math.round() 与 Math.floor()
@Test
public void test03(){
System.out.println(Math.round(-11.5));// -11
System.out.println(Math.round(11.5));// 12
System.out.println(Math.floor(-11.5));// -12.0
System.out.println(Math.floor(11.5));// 11.0
}
// Math.floor() 向下取整
// Math.round() 四舍五入后向上取整
④ Stack 可存储 null, FIFO
@Test
public void test04(){
Stack<Integer> stack = new Stack<>();
stack.add(1); // 换成 push 打印结果也一样
stack.add(null);
stack.add(2);
int len = stack.size();
for(int i = 0; i < len; i++){
System.out.print(stack.pop() + " ");
}
System.out.println();
// 2 null 1
}
底层结构为数组,所以是尾插,弹出pop时,也是从尾部弹出
public synchronized E pop() {
E obj;
int len = size(); // 获取当前数组的长度
obj = peek();
removeElementAt(len - 1); // 弹出最后一个元素
return obj;
}
⑤ 可用于修饰 interface 的有:final 能否用来修饰 interface
final 修饰类,成员变量和方法,不能用于修饰 interface
public 和 default 可用于修饰 interface,而 protected 和 private 不行
⑥ TCP/IP 四层协议:
链路层:
网络层:IP 协议
传输层:TCP 协议
应用层:HTTP 协议
图解 HTTP 关注下
⑦ IP 地址划分:
A 类:0 - 127
B 类:128 - 191
C 类:192 - 223
⑧ 修改表结构:alter table
where 1 = 2, 常用于复制表结构,原数据不要,仅保留表结构