Java Basics

2017-06-07  本文已影响0人  kevinscake

1. Object & Variables

1.1 Object

Everything in Java is Object

1.2 Variables

2. Control Structures

To modify the flow of code in a program

2.1 condition

2.2 loop

for(char c : charArray) {
  ...
}

3. Data Structures

To store data in an organized and efficient manner

3.1 Array

char[] charArray = new char[5];

3.2 ArrayList

List<Character> arrayList = new ArrayList<Character>();

3.3 Maps

Map<String, List<String>> map = new HashMap<String, List<String>>();

4. Primitives & Wrapper

4.1 Primitives & its Object counterpart(Wrapper)

4.2 Primitives Size & Default value

4.3 什么时候使用Primitive,什么时候使用wrapper?

Primitive更efficient,当需要参与的计算非常的直接,不需要处理类型的转换,不需要考虑极大,极小值等等时,优先考虑Primitive。 反之,考虑使用Wrapper。

5. Methods

code reuse

5.1 Access Control

a.k.a Access Modifiers

because of class inheritance, all public methods and variables of a class are inherited by its subclasses. 所有public的东西会被子类继承

同一个包,或者子类(无论同不同包)。因此可以理解为,隔离了非子类且不同包

5.2 Return Types

好处: 在函数定义的时候指明返回值类型,可以使对函数的使用更加明确。

上一篇 下一篇

猜你喜欢

热点阅读