⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linktest.java

📁 Java经典例程 从外国一大学计算机教授出版物下载的代码 经典
💻 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 + -