ユーザーは、使用するツリーを選択する必要があります。
どのツリーをテストしますか (BST、ST、RBT)?
入力を文字列として取得し、それを文字列と比較して、使用するツリーを選択できると思いましたが、間違っていると思います。以下は私が行ったことです
Scanner input = new Scanner(System.in);
System.out.println("Which tree would you like to test (BST, ST, RBT)? ");
treeChoice = input.nextLine();
if(treeChoice == "BST")
{
myTree = new BST<Integer>();
}
else if(treeChoice == "ST")
{
//ST<Integer> myTree = new ST<Integer>();
}
else if(treeChoice == "RBT")
{
//RBT<Integer> myTree = new RBT<Integer>();
}
else
{
System.out.println("Invalid Entry");
}
テストしたところ、出力が無効なエントリでした。
私はこれについて間違った方法で進んでいますか?