class Hoge<T>{
private T var;
public void setVar(T arg){var = arg;}
public T getVar(){return var;}
}
//の様なクラスを
public class Test{
public static void main(String[] args){
Hoge<String> obj = new Hoge<String>();
}
}
//の様にインスタンス化すると
class Hoge{
private String var;
public void setVar(String arg){var = arg;}
public String getVar(){return var;}
}
//の様な内容で生成されるし
public class Test{
public static void main(String[] args){
Hoge<Integer> obj = new Hoge<Integer>();
}
}
//の様にインスタンス化すると
class Hoge{
private Integer var;
public void setVar(Integer arg){var = arg;}
public Integer getVar(){return var;}
}
//の様な内容で生成される。
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme