Ad Hoc Testing vs. JUnit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public class TestSort { /** Tests the sort method of the Sort class. */ public static testSort() { String[] input = {"cows", "dwell", "above", "clouds"}; String[] expected = {"above", "cows", "clouds", "dwell"}; Sort.sort(input); org.junit.Assert.assertArrayEquals(expected, input); } public static void main(String[] args) { testSort(); } } Selection Sort 简单介绍一下了,关注点在junit Simpler JUnit Tests ADD, TDD, Integration Testing More On JUnit (Extra)
but hard to maintain!
Hypernyms, Hyponyms, and Interface Inheritance interface 1 2 3 4 5 6 7 8 9 10 public interface List61B<Item> { public void addFirst(Item x); public void addLast(Item y); public Item getFirst(); public Item getLast(); public Item removeLast(); public Item get(int i); public void insert(Item x, int position); public int size(); } Overriding vs. Overloading override注意加上@Override!!!
Interface Inheritance 基类存放指针问题 Answer: If X is a superclass of Y, then memory boxes for X may contain Y.
From IntList to SLList 事实是在SLList里面添加一个Intlist数据成员
Public vs. Private or Nested Classes 介绍了private
Nested Classes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 public class SLList { public class IntNode { public int item; public IntNode next; public IntNode(int i, IntNode n) { item = i; next = n; } } private IntNode first; public SLList(int x) { first = new IntNode(x, null); } .