Skip to content

Instantly share code, notes, and snippets.

@aiya000
Created December 12, 2014 08:12
Show Gist options
  • Select an option

  • Save aiya000/7a903187883eaa7d18d7 to your computer and use it in GitHub Desktop.

Select an option

Save aiya000/7a903187883eaa7d18d7 to your computer and use it in GitHub Desktop.
/* Java */
public class Test {
public static void main(String[] args){
Hoge<Integer> hoge = Hoge.get(10);
System.out.println(hoge.value);
}
}
class Hoge<T> {
private Hoge(){}
public T value;
public static<T> Hoge<T> get(T value){
Hoge<T> hoge = new Hoge<T>();
hoge.value = value;
return hoge;
}
}
/* C# */
// public class Test {
// public static void Main(string[] args){
// Hoge<int> hoge = Hoge.Get(10);
// Console.WriteLine(hoge.val);
// }
// }
//
// class Hoge<T> {
// private Hoge(){}
// public T val;
//
// public static Hoge<T> Get<T>(T val){
// Hoge<T> hoge = new Hoge<T>();
// hoge.val = val;
// return hoge;
// }
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment