avatar
问两个语法问题# Java - 爪哇娇娃
o*t
1
请问各位有没有拿了生物或是其他的博士硕士学位在公司里或是law firm做 technical
advisor的?我在准备办今年的cap H1,不知道最合适的job classification code
(OES/SOC code)是什么。 想听听大家的意见。十分感谢。
avatar
l*y
2
(一)在generics里,我写一个abstract class A
abstract class A {
...
}
我想写一个B去继承,哪种格式是对的?
1. class B extends A {
...
}
2. class B> {
...
}
3. class B extends A {
...
}
在我的书上例子中,只能找到第2种,比如
class B> {
....
}
(二)java的number class是不是不支持+-*/运算?似乎我直接用e1, e2 extends
Number, 然后做e1 + e2会报错。那个auto-boxing和auto-unboxing是不是只对Integer
, Double这样的类才有用,对Number没用?
avatar
Y*G
3
(2) Auto-Boxing只针对primitive type相对应的类, Number不在其中。
+-*/只能用在某些primitive type的变量。
avatar
n*1
4
class B extends A{
}
和你说的
class B {
}
这两个表达式的意图是不同的

【在 l******y 的大作中提到】
: (一)在generics里,我写一个abstract class A
: abstract class A {
: ...
: }
: 我想写一个B去继承,哪种格式是对的?
: 1. class B extends A {
: ...
: }
: 2. class B> {
: ...

avatar
x*d
5
I rarely use generic outside of collections. they seems all correct but the
meaning is different. I am curious why you need to code something like that,
I guess only for fun, but it is kind of wasting time. Seems you need to
work more on understanding generic the concept than coding.
avatar
L*r
6
class B> means B takes a type E that extends A.
class B extends A is what you need.

【在 l******y 的大作中提到】
: (一)在generics里,我写一个abstract class A
: abstract class A {
: ...
: }
: 我想写一个B去继承,哪种格式是对的?
: 1. class B extends A {
: ...
: }
: 2. class B> {
: ...

avatar
x*d
7
yeah, that is what you want, but 1 should also work. 2 is not subclassing at
all.

【在 L*******r 的大作中提到】
: class B> means B takes a type E that extends A.
: class B extends A is what you need.

avatar
f*n
8
第一个的E是从哪里来的?

【在 l******y 的大作中提到】
: (一)在generics里,我写一个abstract class A
: abstract class A {
: ...
: }
: 我想写一个B去继承,哪种格式是对的?
: 1. class B extends A {
: ...
: }
: 2. class B> {
: ...

avatar
l*y
9
感谢各位大牛的解答。
其实我的想法的这样的:首先写一个
Abstract class A {
//...
}
其中S包括两个字类,S1,S2;
然后写一个B extends A,然后implement一部分函数,这部分函数是针对S1设计的。接
着,再写一个C extends A,这部分函数是针对S2设计的。B和C类似于平行关系,各有
不同办法implement不同的函数。
看了各位的解答,感觉这种设计是不是很糟糕?
avatar
x*d
10
没问题呀。不过觉得你想复杂了。记住要kiss!

【在 l******y 的大作中提到】
: 感谢各位大牛的解答。
: 其实我的想法的这样的:首先写一个
: Abstract class A {
: //...
: }
: 其中S包括两个字类,S1,S2;
: 然后写一个B extends A,然后implement一部分函数,这部分函数是针对S1设计的。接
: 着,再写一个C extends A,这部分函数是针对S2设计的。B和C类似于平行关系,各有
: 不同办法implement不同的函数。
: 看了各位的解答,感觉这种设计是不是很糟糕?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。