bluej を使用して、ユーザーリストのプログラムを作成しています。コードをコンパイルして実行すると、bluej でエラーが発生しません。しかし、クラスの新しいインスタンスを作成すると、何も起こらないように見えます。インスタンスから端末ウィンドウへの行の出力が機能しません。端末ウィンドウでインスタンスの印刷を表示するにはどうすればよいですか?
import java.util.*;
import java.text.*;
public class Main{
private ArrayList<List> userlists;
public Main(){
System.out.print('\f');
System.out.println("this text will show.");
newlist("listname");
}
public void newlist(String listname){
System.out.println("this text will show too!");
List userlist = new List(listname); //terminal does not show lines printed by constructor of List?
userlists.add(userlist);
userlist.printSomeText(); //second attempt to print a line, does not show in terminal.
}
}
public class List {
private String listname;
public List(String ln) {
listname = ln;
System.out.println("this text does not show.");
}
public void printSomeText(){
System.out.println("this text neither.");
}
}
これを実行するには (最初に両方のクラスをコンパイルしてから) bluej のインターフェースで Main クラスを右クリックし、new Main() を選択します。これを行うと、ターミナル ウィンドウが表示されます。
this text will show.
this text will show too!
しかし、それは表示されません:
this text will show.
this text will show too!
this text does not show.
this text neither.
anyエラーは表示されないので、何がうまくいかないのか、2番目の結果を取得する方法を知りたいのですが、これらの4行を示しています。