由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - how to do this?
相关主题
一个关于generics的问题oracle真黑啊
Interview的人问我最新java 版本是多少请问有没有generic的array
Sun的JDK 1.5有什么新特点吗?extending generic class , but not mentioning its parameterized type?
[转载] Java 1.5 Generic 问题菜鸟问关于Java Programming的问题
1999年出版的C,C++,Java语言教程过期了吗??generics这样改对马?
An interesting thing about java generics-do not laugh at me if u think it too basic问个 Generic 的问题
Interesting discussion: java and generics and morehow to copy an Object?
scala - I 服了 UWhat do you think about AOP?
相关话题的讨论汇总
话题: dummy话题: do话题: class话题: ctor
进入Java版参与讨论
1 (共1页)
b*d
发帖数: 75
1
i have a generic class
class Dummy {
public Dummy() {
}
private T dummy;
}
how to instantiate the dummy field in ctor? how to achieve "new T()" like in c+
+?
t*******e
发帖数: 684
2
You cannot instantiate it. Generic typed variables are fed through method input
parameters.
b*d
发帖数: 75
3
ok then can i instantiate dummy in a non-ctor method?

input

【在 t*******e 的大作中提到】
: You cannot instantiate it. Generic typed variables are fed through method input
: parameters.

t*******e
发帖数: 684
4
What's you intent? Describe you use case.
F****n
发帖数: 3271
5
There is no way. Unlike C++, Java Generics is a compile-time thing. You
cannot dynamically create it during time.

in c+

【在 b*d 的大作中提到】
: i have a generic class
: class Dummy {
: public Dummy() {
: }
: private T dummy;
: }
: how to instantiate the dummy field in ctor? how to achieve "new T()" like in c+
: +?

s*****k
发帖数: 604
6
I'm a little confused. Isn't C++ template a "compile-time thing" too?

【在 F****n 的大作中提到】
: There is no way. Unlike C++, Java Generics is a compile-time thing. You
: cannot dynamically create it during time.
:
: in c+

F****n
发帖数: 3271
7
Java template variable declaration, (not type parameters in class definition
), does NOT have any impact on compiled binary code. Search for type erasure.

【在 s*****k 的大作中提到】
: I'm a little confused. Isn't C++ template a "compile-time thing" too?
1 (共1页)
进入Java版参与讨论
相关主题
What do you think about AOP?1999年出版的C,C++,Java语言教程过期了吗??
Re: j2se5.0 anybody triedAn interesting thing about java generics-do not laugh at me if u think it too basic
问一个generic的问题吧Interesting discussion: java and generics and more
再问generic问题:tomcat编译错误scala - I 服了 U
一个关于generics的问题oracle真黑啊
Interview的人问我最新java 版本是多少请问有没有generic的array
Sun的JDK 1.5有什么新特点吗?extending generic class , but not mentioning its parameterized type?
[转载] Java 1.5 Generic 问题菜鸟问关于Java Programming的问题
相关话题的讨论汇总
话题: dummy话题: do话题: class话题: ctor