今、新しくJAVAについて学習しているのですが、ArrayList,LinkedList等についてよくわからないことが出てきたので質問させてください。
ここではArrayListを使用していますがまず
import java.util.ArrayList;
public class test{
public static void main(String args[]){
ArrayList<String> tt=new ArrayList<String>();
String test=" test ";
tt.add(test);
System.out.println(tt.get(0).trim());
}
}
The type ArrayList is not generic; it cannot be parameterized with arguments <String>および
Syntax error, parameterized types are only available if source level is 5.0
と出てコンパイルができません。
試しに
import java.util.ArrayList;
public class test{
public static void main(String args[]){
ArrayList tt=new ArrayList();
String test=" test ";
tt.add(test);
System.out.println(tt.get(0).trim());
}
}
The method trim() is undefined for the type Object
と出てコンパイルできないのです。
配列中のオブジェクトの関数はget()では使えないのですか?