2
class Term <Base, Power>{ //declaration of new class Term
Base a;
Power b;
public Term(Base a, Power b) {
this.a = a;
this.b = b;
}
}
public static void in(){ //trying to use this class in another class's method
Scanner input = new Scanner(System.in);
System.out.println("Enter two integers: ");
Term<Integer, Integer> t;
t.a = input.nextInt();
t.b = input.nextInt();
}
我得到一個「t可能未初始化」的錯誤。我不明白如何從製作基本和力量這樣的泛型並將它們用作整數,而我嘗試的所有東西似乎都是錯誤的。我真的可以使用一些幫助,但我不認爲我理解的術語足以進行搜索。如何在java中實現元組類的初始化
感謝您的任何幫助。
編輯:非常感謝!
'Term t;'未初始化。 –
Maroun
2014-10-05 14:22:28