Yangyehan&UndGround.

java笔记

Word count: 5.1kReading time: 24 min
2023/06/29

java笔记

使用javadoc生成docs

1
2
3
4
5
生成指定文件的javadoc
# javadoc -d docs file.java

生成所有文件的javadoc
# javadoc -d docs *.java

Array And ArrayList

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Array及其用法
# arraycopy(Object src,int start1,Object des,int start2,int length); methods array to copy array(两个起点一个长度,前copy from,后copy to)
# int(Object/String/Char)[] = new int[6](...);
# array[0]=1; set Methods
# int a = array[0];get Methods
# int[] a = new int[]{1,2,3}; initials arrays



ArrayList及其方法
# ArrayList<Object> list = new ArrayList<Object>();
# list.add(new Object()); set Methods
# list.size(); return int
# list.contains(obj); return boolean
# list.indexof(obj); return index if there is no obj return -1;
# list.isEmpty(); return boolean
# list.remove();
# list.get(4); get Methods

Array and Array Difference
## An array needs to know its size at time of creation, whereas an ArrayListdoes not:
# new String[6];
# new ArrayList<E>();

## To assign an object in a regular array, you must assign it to a specific index.
# myList[4] = b; myArrayList.add(b);


String Class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
## charAt(int index) return character
## indexof(char '')
## indexof(string "")
## length()
## lastindexof(char '')
## lastindexof(string "")
## boolen equals(obj)
## int compareTo(obj) return -1 or 0 or 1
## substring(int index1,int index2) excluding index2
substring(index) from index to end
## "".concat("")
## toUperCase()/toLowerCase()
## toString()
## split(":") return String[]
## void getChars(i,j,A,k):
returns characters from i to j (excluding), and stores them into array A starting from A[k].
## replace(old,new)
## StringTokenizer(s,"nu",true)
new mystr = new StringTokenizer("23 34 34"," ",true);
mystr.hasMoreTokens() mystr.nextToken() 注意两个方法

![image-20230610172322392](/Users/mac/Library/Application Support/typora-user-images/image-20230610172322392.png)

![image-20230610172341160](/Users/mac/Library/Application Support/typora-user-images/image-20230610172341160.png)

System.out.printf

![image-20230610175236398](/Users/mac/Library/Application Support/typora-user-images/image-20230610175236398.png)

![image-20230610175247323](/Users/mac/Library/Application Support/typora-user-images/image-20230610175247323.png)

about 二维数组with for loop vs for each

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
int[][] array =new int[][]{{1,2,3},{1,2,3},{1,2,3,4}};
//use for each
System.out.println("======with for each first======");
for(int[] i :array){
for(int j=0;j<i.length;j++)
{
System.out.print(i[j]+" ");
}
System.out.println();
}

System.out.println("========with for each second=======");
System.out.println("array.length:"+array.length);
for(int i=0;i<array.length;i++){
for(int j :array[i]){
System.out.print(j+" ");
}
System.out.println();
}

System.out.println("========with two for loop=======");
for(int i=0;i<array.length;i++)
{
for(int j=0;j<array[i].length;j++)
{
System.out.print(array[i][j]+" ");
}
System.out.println();
}

System.out.println("========with two for each=======");
for(int[]i:array)
{
for(int j:i){
System.out.print(j+" ");
}
System.out.println();
}

![image-20230610141501630](/Users/mac/Library/Application Support/typora-user-images/image-20230610141501630.png)

java常见的工具类

1
2
3
4
5
# java.util.*
# java.io.*
# java.lang.*
# java.awt.*
# java.swing.*

MathClass

1
2
3
4
5
6
7
8
9
10
# • Math Class:
– Doesn’t have instance variables.
– Can’t make an instance of class.

## methods
# Math.random()--->return a double between 0.0-1.0(include)
# Math.round(float a) ---->return a round int
# Math.abs(double a)---->return a absolute double
# Math.max(int a,int b)
# Math.min(int a,int b)

关于static 和 final

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//when use static only
it can be autometic initialised,when class loading
public static int a;

//when use final only
it must be initialised when declared or in the constructor
public class test{
public final int a;
test()
{a=0;}
}

//when use final and static
it must initialised when declared,but not allowed in the constructor
because in the static valiables are created when class loading,but constructor is invoked when the instance is created
public static final int a =0;


Object 类提供的API 方法

1
2
3
4
# .equals()
# .toString()
# .hasCode() return a object unique ID according to it's memory address
# .getClass() return CLass of the object

包装器类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//八种基本数据类型对应的包装器类分别为:Byte、Short、Character、Integer、Long、Float、Double、Boolean。
//常用概念,装箱与拆箱
//创建包装器类对象
Integer i1 = new Integer(5);//value属性的值不可以更改指向
System.out.println(i1);
Integer i2 = new Integer("123");//字符串内只能包含数字
System.out.println(i2);
//传参传对应基本数据类型的数字或,只包含对应类型数字的字符串
//注意两个东西,valueof()和intValue();
// intValue()用来拆箱,将Integer类型的数字转换为int类型的数字
int num = new Integer(5).intValue();
//valueof()用来将字符串转换为Intger类型,注意字符串只能是数字
Integer n = new Integer.valueof("123")
Integer.parseInt("123")

==================
Example: Converting a String to a primitive value.
String str1 =10”;
String str2 =123.45”;
String str3 =true”;
int i = Integer.parseInt(str1);
double d = Double.parseDouble(str2);
boolean b = new Boolean(str3).booleanValue();
  • 关于byte的计算问题

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    //1.byte short char 在进行运算的时候会进行强制类型转换为int后再计算
    byte b=1,a=2
    b=a+3;
    //应为:b = (byte)(a+3)

    //2 a+=1
    byte a =1;
    a+=1;
    //在编译时会 byte a = (byte)(a+1),因此不会报错

    //3. final 字符型
  • 关于X++和++x的问题

    1
    2
    ## the first increasement(x++) of the value x is add by 1 after x used;
    ## the second increasement(++x) of the value x is add by 1 before x used;

http://t.csdn.cn/2WcJi ==和equals()的区别

http://t.csdn.cn/5N6b7 子类和父亲类的关系

http://t.csdn.cn/E2zFr interface和抽象类的区别

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
与abstract class有一定的异同点
相同点:显然的是interface与abstract class都是由abstract关键字修饰的,所以两者都是不可以实例化,同时为了本身有意义,两者分别需要实现类和子类去实现已经声明的抽象方法。
不同点:
①interface是通过implements来实现,而abstract class需要通过extends关键字由子类继承。
②一个类可以实现多个interface,但是一个类只能 继承一个abstract class
③对于interface而言,强调的是某一个功能的实现,例如USB接口功能,里边定义“传输功能”抽象方法,可以通过U盘类实现里面的抽象传输功能,可以通过打印机类实现抽象传输功能,在乎的是有这样一个功能,至于被谁实现这是不被关心的。而对于abstract class则更加强调的是所属关系,在一个vehicle类中,定义一个行驶距离的抽象方法,计算燃料效率的抽象方法,然后通过子类的继承实现抽象方法,可以发现方法与类之间有着某种特定关系。总而言之两者在第三点上的差异有,但是不大,无需过多在意。
④在abstract class中不是所有的方法都有abstract修饰,意味着可以有非abstract修饰的方法,此时方法中一定有方法体,所以说对于抽象方法的定义,在abstract class中是一定需要显式用abstract修饰,而在interface中则不一样,默认就有abstract修饰,所以abstract关键字也可以省去。
⑤abstract class可以使用public,protected修饰符修饰,而interface只能使用public修饰符修饰。
由上可见,interface是比abstract class更加抽象的一个结构。


抽象类可以有构造方法,但是不能直接实例化
而接口是不能有构造方法滴
在抽象类中可以有构造方法,只是不能直接创建抽象类的实例对象,但实例化子类的时候,就会初始化父类,
不管父类是不是抽象类都会调用父类的构造方法,初始化一个类,先初始化父类。

getClass返回类名称

1
2
3
4
// 一般:
Counter c = new Counter();
c.getClass.getName();
//如果在类里面,可直接用getClass().getName()返回类名字

ArrayList数组链表

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//ArraryList和数组的区别
//不定长,具备add(),get()等方法,不使用[],存取
//(1) 创建⼀个flower链:
ArrayList<Flower> myList = new ArrayList<Flower>();
//(2) 添加元素
Flower f = new Flower();
myList.add(f);
//(3) 删除元素
myList.remove(f);
//(4) 求元素个数
int size = myList.size();
//(5) 判空:
boolean empty = myList.isEmpty();
//(6) 查看某元素位置
int index = myList.indexOf(f);
//(7)判断是否包含某元素
boolean inIt = myList.contains(f);
//(8)查看某位置元素
myArrayList.get(4)

Super方法

1
2
3
//当在子类对象中,子类想访问父类的东西,可以使用“super.”的方式访问。例如:方法覆盖后,子类内部虽然重写了父类的方法,但子类也想使用一下父类的被覆盖的方法,此时可以使用“super.”的方式。当子类中出现和父类一样的属性或者方法,此时,你要想去调用父类的那个属性或者方法,此时“super.”不能省略。

参考链接:http://t.csdn.cn/oD06j

interface and abstract

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*interface is 100% abstract
*abstract 是一个class(含有至少有一个abstract method)
*interface can extants more than one interfaces,but it neither can extant *from superclass
*a subclass just can extant one superclass,but can implement more than one *interfance
*interfance and abstract both hava not instances.
*interface 中的的methods are all public whatever it declare as plubic.
*/

/*
*interface中的变量默认是包访问级别,方法默认是public的,若想在别的包里面也能访问变量可以
*添加public修饰
*注意 interface中不能含有protected 修饰的变量或者方法,因为protected比默认的权限低
*/

/*
*在接口中声明的变量必须赋初值,(接口默认所有的变量常量==>public static final int d=10 /int d =10)
*/
/*下面的例子声明
public interface test {
final static int d = 10;
static final int a =10;
static int r =1;
final int s = 3;
public int f =4;
int g =4;
public static final int o =9;
public final static int h =8;

}
*/

![image-20230410195411943](/Users/mac/Library/Application Support/typora-user-images/image-20230410195411943.png)

1
2
3
4
5
6
7
//在interface中我们可以使用default在接口中实现了一个默认方法和static 在接口中可以来实现一个静态方法
//default methods can be overriden in the instance of the interface
//static methods can not be overriden in the instance of interface
//在interface 中如果含有static methods,可以直接使用 接口名.static方法名来访问该方法
//在java 接口中,当两个接口都定义了相同的默认方法时,实现类必须使用super来区分
//as TestInterface1.super.show(),TestInterface2.show()

![image-20230609175742050](/Users/mac/Library/Application Support/typora-user-images/image-20230609175742050.png)

![image-20230410204813552](/Users/mac/Library/Application Support/typora-user-images/image-20230410204813552.png)

  • heap and stack

1
2
3
4
5
6
7
8
9
//local variable on the stack
//instance varialbe on the heap
local variables include the values in methods and the parameters and the referance variables;
in the stack,stack will keep the methods state,the executing methods will be on the top of stack;
instance variables include the variables in class but outside methods,objects that referance variables refer to;

//方法,方法的参数,方法里面的成员变量,形参(referance variables)都在盏中
//类,类的成员变量(在类中,除了方法外的变量),类的实例放在堆中
//常量池中储存的是final定义的常量,和Stirng双引号内的数据(String a = "123")
  • super

    1
    在子类构造器中一般调用super来调用父类的有参构造方法来初始化父类as super(name),如果不使用,一般默认调用父类无参构造函数,和super()一样
  • GC (Garage collection)

    1
    2
    3
    //Object的生命周期只与referance variable 相关
    //once if referance variable lost(unalive),the Object will be GC to obtain

    ![image-20230411204852231](/Users/mac/Library/Application Support/typora-user-images/image-20230411204852231.png)

Static 方法只能引用static变量,不能直接引用非static变量

Static方法在可以不用声明对象直接调用

Java GUI

框架 组件 容器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//容器里面可以 添加框架,组件,容器
//框架里面可以添加组件
//常见的容器有面板,框架
JPanel jPanel =new JPanel();
JButton myButton = new JButton();
jpanel.add(myButton);
//框架
JFrame jFrame =new JFrame();
jFrame.getContentPane().add(jPanel); //将框架转换为容器再添加jPanel
//输入框
//创建JTextField,16表示16列,用于JTextField的宽度显示而不是限制字符个数
JTextField textField = new JTextField(16)
TextField():创建一个默认长度为一个机器字符长的文本框

TextField(int n):创建一个指定长度为n个机器字符长的文本框

TextField(String s):创建一个文本框,该文本框的初始字符串为s

TextField(String s,int n):创建一个文本框,n为字符长,s为初始字符串

2.常用方法

public void addActionListener(ActionListener l):给文本框增加监视器

public void setText(String s):设置文本框中的文本为s,文本框中先前的文本将被清除

public String getText():获取文本框中的文本

//label里面设置img
Jlabel l =new Jlabel();
Icon icon = new ImageIcon("src/huasacm.png");
l.setIcon(icon);


//关于Jpanel中的重新绘制问题
//可以使用removeAll()方法后重新添加组件和删除组件
//但是要注意使用完removeAll()后需要调用repaint()和revalidate();
//区别
/**
panel.repaint() 和 panel.revalidate() 都是用于更新 JPanel 显示内容的方法。

panel.repaint() 会调用 Swing 的 paintComponent() 方法来重新绘制
JPanel。当您更改了 JPanel
的内容并希望立即更新屏幕上的显示内容时,此方法非常有用。但是,如果 JPanel
使用了布局管理器,则 repaint()
可能不会导致布局重新计算,因此如果您更改了布局,则应同时调用 revalidate()。

panel.revalidate() 用于告诉布局管理器需要重新布局 JPanel 中的组件。当您向 JPanel
添加或删除组件时,需要调用
revalidate(),以便布局管理器可以正确地调整组件的大小和位置。

总之,如果您更改了 JPanel 的内容但未影响其大小,请使用 panel.repaint()
进行更新。另一方面,如果您更改了 JPanel
的内容并影响了其大小(例如添加或删除组件),则应调用 panel.revalidate()
来更新布局。如果您不确定要使用哪种方法,则可以同时调用它们两个来确保同时更新布局
和绘制。
**/

ActionListener接口的使用

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//别忘了导包 import java.awt.event.*;
//该接口只用实现一个方法叫做actionPerformed(ActionEvent arg0)这个方法
class ButtonListener implements ActionListener {
public void actionPerformed(ActionEvent arg0) {
/*content*/
}
}
//给对象绑定监听
ButtonListener button_listener = new ButtonListener();
button.addActionListener(button_listener);
//给对象移除监听
button.removeActionListener(button_listener);


/*
*example
*/
package technology;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MyFirstActionListener extends JFrame {
final static long serialVersionUID = 1L;
Container container = getContentPane();
JButton button = new JButton("点击我");

class ButtonListener implements ActionListener {
int x = 0;

public void actionPerformed(ActionEvent arg0) {
MyFirstActionListener.this.button.setText("我被点机了" + (++x) + "次");
}
}

public MyFirstActionListener()
{
super("JFrame窗体");
this.setBounds(200, 100, 200, 200);
button.addActionListener(new ButtonListener());
container.add(button);
this.setVisible(true);
}

public static void main(String[] args)
{
new MyFirstActionListener();
}
}


LayoutManger

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//1.FlowLayout
/*The layout manager should be established before any components are added to the container.
FlowLayout类中常见的构造方法:
public FlowLayout()
public FlowLayout(int alignment)
public FlowLayout(int alignment,int horizGap,int vertGap)
其中的alignment参数表示组件在每一行的具体摆放位置,例如:设为0时,每一行的组件将被指定按照左对齐排列。设为1,中间。设为2,右边。
horizGap与vertGap,分别以像素为单位指定组件间的水平与垂直间隔。
*frame.pack();
*这是Java Swing中用来将组件添加到容器并根据组件的大小调整容器大小的方法。它会根据组件的大小和布局管理器的规则,自动调整容器的大小并将组件添加到容器中。这个方法要在创建完所有组件之后调用,以便能够正确地确定容器的大小和布局。
*/
import java.awt.*;
import javax.swing.*;
public class csdn {
public void test() { //定义一个test方法
JFrame frame=new JFrame("这是窗体的名字"); //建个窗体
JButton button=new JButton("登录"); //建个按钮
JLabel lable=new JLabel("这是一个JFrame窗口"); //建个Lable标签
JPanel panel=new JPanel(); //来个面板

panel.add(lable); //面板里添加Lable
panel.add(button); //面板里添加按钮

frame.setLayout(new FlowLayout(0));//调用流布局,设为0时,每一行的组件将被指定按照左对齐排列
frame.getContentPane().add(panel); //将窗体转换为容器再添加上面板
frame.pack();
//设置窗体可见
frame.setVisible(true);
}

public static void main(String[] args) {
// TODO Auto-generated method stub
csdn c= new csdn();
c.test();

}
}
/*最后显示的结果是文字和按钮都在左边*/


GridLayout

![image-20230601185710952](/Users/mac/Library/Application Support/typora-user-images/image-20230601185710952.png)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
网格布局管理器将容器划分为网格,所以组件可以按照行和列进行排列。

此布局中每个组件大小相同
组件会按从左往右,由上而下的加入到网格中
每个组件都会填满网格,改变窗体大小,组件大小也会随之改变。
两种主要构造方法:
public GridLayout (int rows , int columns)
public GridLayout (int rows , int columns , int horizGap , int vertGap)
参数horizGap与vertGap指定网格间的距离,前者指水平距离,后者指垂直距离
*/
//example
import java.awt.*;
import javax.swing.*;
public class csdn {
public void test() { //定义一个test方法
JFrame frame=new JFrame("这是窗体的名字");
//创建5个按钮
JButton button1=new JButton("1");
JButton button2=new JButton("2");
JButton button3=new JButton("3");
JButton button4=new JButton("4");
JButton button5=new JButton("5");

frame.setLayout(new GridLayout(2,3,5,5));//设置2行3列网格

frame.add(button1);
frame.add(button2);
frame.add(button3);
frame.add(button4);
frame.add(button5);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置关闭窗体结束应用程序
frame.setSize(400,400);
frame.setVisible(true);

}

public static void main(String[] args) {
// TODO Auto-generated method stub
csdn c= new csdn();
c.test();
}
}
/*注意观察
我这个例子设置了5个按钮
最初定义了2行3列的网格
但是由于组件不够
所以只显示6个格子
其中一个是空格
也就是说无论如何都会显示为矩形,
但如果我们将2行3列改为3行3列
我们会发现,界面显示的是3行2列
所以通过测试我们知道网格布局先满足行数再满足列数
*/

BorderLayout

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//直接看例子
import javax.swing.*;
import java.awt.*;

public class BoderLayoutDemo extends JFrame {
public BoderLayoutDemo() {
setTitle("BorderLayoutDemo");
Container content = getContentPane(); content.setLayout(new BorderLayout());
content.add(BorderLayout.NORTH, new JButton("North"));
content.add(BorderLayout.SOUTH, new JButton("South"));
content.add(BorderLayout.EAST, new JButton("East"));
content.add(BorderLayout.WEST, new JButton("West"));
content.add(BorderLayout.SOUTH, new JButton("South 2"));
content.add(BorderLayout.CENTER, new JButton("Center"));
}
public static void main(String args[]) {
BoderLayoutDemo frame = new BoderLayoutDemo();
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}

![image-20230601190358367](/Users/mac/Library/Application Support/typora-user-images/image-20230601190358367.png)

一些常见的概念问题:

  • Exception Difine:

    1
    ## an Object that signals to the calling code,the occurence of an unusual condotion;
  • what the difference between the private ,public ,protected access modifiers

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    ## public: interface access
    disadvange: we have little control over how it is accessed
    ## protected: Package member and classes which extends it;
    ## default: Package members(defalut is achieved by ot adding a qualifier)
    ## private: class only
    advange: we have complete control over how the data member is accessed

    • public
    – public instance variables and methods are inherited
    • protected
    – protected instance variables and methods are inherited
    • private
    – any private instance variables and methods
    are not inherited and cannot be seen by the subclass
  • what is Object

    1
    ## An object is an instance of a particular class.
  • what is class

1
2
3
4
## the class defines attributes and operations exposed by one or more related object
## An object is defined by a class.
## In Java, a class is to:
# – define a kind of object or in other words, to define a data type
  • what is Polymorphism

    1
    2
    3
    4
    5
    6
    7
    8
    9
    ## Polymorphism → Using a single definition (superclass) with different types (subclass).

    ## about Interface
    Java’s “multiple inheritance” is at interface level only!
    An interface allows polymorphic capabilities
    without the problems of multiple inheritance.

    ## how interface implements mutiple ingeritance
    Since an interface has NO implemented methods, multiple inheritance is not a problem, as no class inherits a "finished" method.
  • what is method overriding

1
2
3
4
## we redefined the inherited methods
• Subclass can redefine a superclass method
– When the method is mentioned in the subclass, then the subclass method version is used.
– Can access the original superclass method with super.methodName
  • What difference between pass by value and pass by
1
## pass-by-value == pass by copy
  • What is constructor
1
## A constructor is a special method with same name as the class name,used for initialisation.

instance variables will be initialised with defaut 0,but local variables will not be initialised;

  • What is the difference between the this() and super()

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    this. vs super.
    ## this used to access the class itself‘s variables and methods
    ## super used to access the superclass's valriables and methods

    this() vs supser()
    ## this() used to call the class constructor
    ## super() used to call the superClass constructor
    when in the subclass, we want to call superClass's constructor we use super();
    when int the subclass, we want to cal class's constructor or in same class we want to call a constructor from another overload one we use this()(maybe with arguments);

    # A constructor can have a call to either super() or this() but not toboth!
  • what is downcasting

    1
    2
    ## Covert SuperClass reference to a subClass reference
    # Can only be done when superclass reference is actually referring to a subclass object.
  • what the defference between array and ArrrayList

    1
    2
    ## ArrayList can vary in length,but array can not
    ## ArrayList have a richer API than array
  • what is javadoc

    1
    ## javadoc is a fomal description(or API) of your java code;it means someone who want to use your code no need to read your code,can understand what your code does;
  • Javadoc tag

    1
    2
    3
    4
    5
    6
    7
    生成指定文件的javadoc
    ## javadoc -d docs Examples.java

    ## @author (classes and interfaces only,required)
    ## @version(classes and interfaces only,required)
    ## @param(methods and constructors only)
    ## @return(methods only)
  • recursive

    1
    2
    3
    包含两个部分
    ## base case
    ## recursive call
  • three main concepts about creating GUI

    1
    2
    3
    4
    5
    ## component: An object user can see on the screen and can interact with
    ## container: A component that can hold other components
    ## Event:An action trigger by the user

    Desigining a GUI involves creating components and add components into containers,and arranging for the program to respond to the events

IMG_9F3AD1B60365-1

IMG_1015

CATALOG
  1. 1. java笔记
    1. 1.1. 使用javadoc生成docs
    2. 1.2. Array And ArrayList
    3. 1.3. String Class
    4. 1.4. System.out.printf
    5. 1.5. about 二维数组with for loop vs for each
    6. 1.6. java常见的工具类
    7. 1.7. MathClass
    8. 1.8. 关于static 和 final
  • Object 类提供的API 方法
    1. 0.1. 包装器类
    2. 0.2. 关于byte的计算问题
    3. 0.3. getClass返回类名称
    4. 0.4. ArrayList数组链表
    5. 0.5. Super方法
    6. 0.6. interface and abstract
    7. 0.7. heap and stack
    8. 0.8. super
    9. 0.9. Static 方法只能引用static变量,不能直接引用非static变量
    10. 0.10. Static方法在可以不用声明对象直接调用
  • Java GUI
    1. 0.1. 框架 组件 容器
    2. 0.2. ActionListener接口的使用
    3. 0.3. LayoutManger
    4. 0.4. GridLayout
    5. 0.5. BorderLayout
    6. 0.6. 一些常见的概念问题: