1 回顾 |
| |
1.1 toString() |
| |
|
System.out.println(c);
1.2 日期 |
| |
1.2.1 Date |
| |
| ||
1.2.2 SimpleDateFormat |
| |
| ||
1.2.2.1 Date-->String |
| |
| ||
1.2.2.2 String--->Date |
| |
|
1.2.3 Calendar |
| |
|
.get(DATE_OF_MONTH)
2 static |
| |
| ||
2.1 java的数据存储的模式 |
|
static{ System.out.println("静态代码块"); } { System.out.println("代码块...."); } public StaticDemo(){ System.out.println("无参构造器....");
|
public static void main(String[] args) { StaticDemo s = new StaticDemo(); StaticDemo s1 = new StaticDemo(); } | |
2.2 银行取钱 |
|
2.2.1 第一种情况 |
2.2.2 第二种 |
| |
|
this: 当前对象的引用
this.name: 当前对象的name属性
2.3 使用场景 |
| |
|
1. 输入一个字符串
sc.nextLine();
2. 输入一个数字---》int
Integer.parseInt(sc.nextLine());
3. 输入一个浮点数--->double
Double.parseDouble(sc.nextLine())
3 final |
| |
|
常量的缺点,不能表示具体的意思。
符号常量,变量+final--》不可变的量
| ||
3.1 出现在变量前(方法) |
| |
| ||
3.2 出现引用前面 |
| |
|
final Car c = new Car();
c= new Car(); c=null; | ||
3.3 出现在属性 |
| |
| ||
4 访问控制符 |
| |
|
private (默认) [protected] public
5 this关键字 |
|
可以调用构造器
tips: this()一定出现在第一句。 |
6 包装类型 |
| |
|
6.1 int为例 |
| |
|
| ||
6.2 包装 |
|
基本类型--->包装类型
| ||
6.3 拆包 |
| |
|