📄 linktest.java
字号:
import javagently.*;
import java.io.*;
class LinkTest {
/* The LinkTest program J M Bishop Aug 2000
*
* Small test program to
* Illustrate linking of objects through references
*/
LinkTest () throws IOException {
Coffee coffees = null;
String name;
Stream in = new Stream ("names.dat", Stream.READ);
// create a list headed by coffees
System.out.println("Coffees on the list");
for (int i=0; i<=4; i++) {
name = in.readString();
System.out.println(name);
coffees = new Coffee (name, coffees);
}
System.out.println("\nCoffees on the list");
// Copy the head of the list
Coffee list = coffees;
// Print out the list
for (int i=0; i<=4; i++) {
System.out.println(list.name);
list = list.link;
}
}
public static void main (String args []) throws IOException {
new LinkTest();
}
class Coffee {
/* Small test class with a link */
Coffee (String s, Coffee c) {
name = s;
link = c;
}
String name;
Coffee link;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -