Skip to content

Commit

Permalink
add many things
Browse files Browse the repository at this point in the history
  • Loading branch information
lzz19980125 committed Mar 16, 2022
1 parent 3dc1aa1 commit 2843c32
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 9 deletions.
2 changes: 0 additions & 2 deletions lecture/src/lecture4_3.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public static Dog max(Dog[] items){

public static void getWords(String inputFileName){
List<String> lst = new ArrayList<String>();
In in = new In();

}
}

Expand Down
39 changes: 39 additions & 0 deletions lecture/src/lecutre4_1.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,44 @@ public static String smallest(SList<String> input){
}
}

class SLList<Item> implements List61B<Item>{

@Override
public void addFirst(Item x) {
}

@Override
public void addLast(Item y) {
}

@Override
public Item getFirst() {
return null;
}

@Override
public Item getLast() {
return null;
}

@Override
public Item removeLast() {
return null;
}

@Override
public Item get(int i) {
return null;
}

@Override
public void insert(Item x, int position) {
}

@Override
public int size() {
return 0;
}
}


4 changes: 1 addition & 3 deletions lecture_4.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static void main(String[] args) {

试想一下,一旦有很多子类,那么这个工作量将会比没有使用向上转型大很多。这也表明向上转型还有个优点就是提高了代码的简洁性。

**重点:经过向上转型之后,在利用.操作符访问时,如果访问的是对象的属性,则编译的话就是看父类,运行同样是看父类;如果访问的是方法,编译就看父类,运行则看子类;如果访问的是父类中表明的static methods,尽管子类已经进行override,但编译和运行都是看父类**
**重点:经过向上转型之后,在利用.操作符访问时,如果访问的是对象的属性,则编译的话就是看父类,运行同样是看父类;如果访问的是方法,编译就看父类,运行则看子类;如果访问的是父类中标明的static methods,尽管子类已经进行override,但编译和运行都是看父类**

### High order function(高阶函数,HOF)

Expand Down Expand Up @@ -377,8 +377,6 @@ Exception in thread "main" java.lang.ClassCastException: class SList cannot be c
at lecture4_2.main(lecture4_2.java:14)
```



### 内置Comparable接口

事实上,java内置的Comparable接口与我们构建的Ourcomparable接口仅有细微的差别,其内置接口定义如下:
Expand Down
Empty file added lecture_5.md
Empty file.
Binary file added out/production/lecture/Benz.class
Binary file not shown.
Binary file added out/production/lecture/Car.class
Binary file not shown.
Binary file modified out/production/lecture/Dog$NameComparator.class
Binary file not shown.
Binary file modified out/production/lecture/Dog.class
Binary file not shown.
Binary file added out/production/lecture/SLList.class
Binary file not shown.
Binary file modified out/production/lecture/lecture4_3.class
Binary file not shown.
6 changes: 2 additions & 4 deletions 未完成的任务.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# 双向链表(Intnode中的prev指针)(project1 待完成)
### 双向链表(Intnode中的prev指针)(project1 待完成)

# 你泛型还没有真正弄懂
### lecutre 4.4中所有的excerises都没有做

# 继承与接口实现中java的向上转型与向下转型!

# java静态类型与动态类型(向上转型后**dynamic method selection**,并不适用于overloaded方法)

0 comments on commit 2843c32

Please sign in to comment.