(자바 사용하기) B- 트리 인 일반 클래스를 구현 중입니다. 사용자가 프로그램을 실행할 때 트리의 유형 (정수, 문자, 이중 또는 문자열)을 결정하는 인수를 제공 할 수 있습니다. 내 주요 방법은일반 클래스의 객체 만들기
는이 코드가 있습니다
// Get user input and split it into tokens
// Tokens[1] = the type specified by the user
if(tokens[1].equals("DOUBLE"))
BTree<Double> t = new BTree<Double>();
else if(tokens[1].equals("CHARACTER"))
BTree<Character> t = new BTree<Character>();
else if(tokens[1].equals("INTEGER"))
BTree<Integer> t = new BTree<Integer>();
else if(tokens[1].equals("STRING"))
BTree<String> t = new BTree<String>();
를하지만이 (가) if 문이있는 경우 컴파일러는 불평. 제거하면 잘 컴파일되고 실행됩니다./어떻게 해결할 수 있습니까? 사용자가 유형을 제공 할 수 있도록 제공되는 유형에 따라 트리가 생성됩니까? 감사. 여기
는 컴파일러 출력의 일부 : 가C:\Users\User\Desktop>javac *.java
Main.java:42: error: cannot find symbol
BTree<Double> t = new BTree<Double>();
symbol: variable BTree
location: class Main
Main.java:42: error: cannot find symbol
BTree<Double> t = new BTree<Double>();
symbol: variable Double
location: class Main
Main.java:42: error: cannot find symbol
BTree<Double> t = new BTree<Double>();
symbol: variable t
location: class Main
.. 이상 존재하지만 유형
컴파일러 로그를 제공 할 수 있습니까? – mishadoff
질문에 편집했습니다 : – Tim
질문 제목 : "추상적 인 클래스의 객체 만들기"하지만 실제로는 다른 것을 요구하고 있습니다. – anubhava