20145321 "Java Program Design" 3rd week study summary textbook Study content summary fourth chapter
4.1 Classes and objects
1、定义类:类定义时用关键词 class。 一个原始码中可以有多个类定义,但只能有一个公开类,且主文档名必须与公开类名称相同。 新建对象:用关键词 new。(对象是类的实例)2、构造函数:构造函数是与类名称同名的方法,即构造函数的名称要与所在类的名称一致。 例:Clothes2(String color, char size)3、标准类: java.util.Scanner————建立Scanner实例 Scanner scanner=new Scanner(System.in) Scanner对每个基本类型,都有相对应的 next xxx() 方法 java.math.BigDemical————得到更好的精确度。 提供加减乘除运算plus()、substract()、mutiply()、 divide()4、对象指定与相等性:基本类型中,=是赋值给变量,==是比较两变量值是否相等;而在操作对象时,=是将某个 名牌绑到某对象,==是比较两名牌是否绑在同一对象。
4.2 Basic Type Packager
1、让基本类型像对象一样操作:long-Long、int-Integer、double-Double、float-Float、 boolean-Boolean、byte-Byte Integer操作中:doubleValue()将打包值以double类型返回;compareTo()方法,可与另一个Integer 对象进行比较。
4.3 Array objects
1、数组在Java中就是一个对象。 一维数组用int[],二维数组用int[][]。通过cords.length得知有几列 ,通过cords[x].length得知每 列有几个元素。2、数组作为一个对象,每个类型都有初始值,另外数组的索引从0开始。数组赋初值Arrays.fill。 使用的时候不能超过其索引范围,否则会出现ArrayIndexOutOfBoundsException的错误。3、数组复制:可以通过System.arraycopy()与Arrays.copyof()这些类快速复制一个数组。
4.4 String Object
1、字符串本质是打包字符数组的对象,是java.lang.String类的实例。2、以“”包括的字符串,只要内容完全相同,则只会建立一个String实例,并在字符串池中维护。
Fifth Chapter
5.1 What is encapsulation
1、封装对象初始流程:定义构造函数实际上就是一种封装的初始流程。2、封装实际上使用方法将类的数据隐藏起来,控制用户对类的修改和访问数据的程度,隐藏对象细节,将对象当作 黑箱进行操作,可将函数、流程、值都封装在类中,即可直接调用。
5.2 Class Syntax details
1、public 权限修饰:用在类前,表示其是公开类,可以在其他包的类中调用。用在函数前,表示其他包的类可 以直接调用此函数。2、this 关键字:this代本类对象的引用,当在函数内需要用到调用该函数的对象时,我们就可以使用this。3、static 类成员:用于修饰成员(成员变量和成员函数),不会让个别对象拥有,而是属于类。 在static方法中不能出现this关键字,static方法中不能用非static数据或方法成员。
Problems in teaching materials learning and the solving process
The two chapters of the knowledge is more abstract, complex difficult to understand, feeling and the previous three chapters is not a level. Encountered to see not understand a few times, ask genius, more dozen code to slowly understand. Although it is only according to the book Code debugging, but still can make people understand a lot of knowledge.
Problems in code debugging and the resolution process
Because it's all about the code on the books and some little exercises, there's no problem at the moment. Other code can be visible on the host.
Learning progress Bar
|
lines of code (new | /Cumulative)
Blog volume ( | new/cumulative)
Learning time (new/cumulative) |
Important growth |
| Goal |
3500 rows |
28 Articles |
300 hours |
|
| First week |
150/150 |
1/2 |
20/20 |
|
| Second week |
150/300 |
1/3 |
20/40 |
|
| Third week |
150/400 |
1/4 |
20/60 |
|
| Week Four |
|
|
|
|
20145321 Java Programming 3rd week of study summary