Redian新闻
>
各位前辈,国内翻墙不易,真诚请教前辈们offer选校建议,谢谢你们
avatar
各位前辈,国内翻墙不易,真诚请教前辈们offer选校建议,谢谢你们# ChemEng - 化学工程
x*n
1
请问下面一段代码中,为什么第8行处能compile通过而第14行不行?
我的理解是,exceptions 事实上是List (因此所有Exception的子类都可
以包含),而numbers事实上就是List,那么14行也理应可以通过才对?
1 ArrayList < ? super IOException > exceptions =
2 new ArrayList < Exception > ();
3 IOException e1 = new IOException("Problem 1");
4 IOException e2 = new IOException("Problem 2");
5 FileNotFoundException e3 = new FileNotFoundException("Problem 3");
6 exceptions.add(e1);
7 exceptions.add(e2);
8 exceptions.add(e3);
9 System.out.println(exceptions);
10
11 List numbers = new ArrayList ();
12 numbers.add(232);
13 Number n = new Integer(2);
14 numbers.add(n); //can't compile
非常感谢!
avatar
s*r
2
《诗情画意谈力学》序及目录
王 振 东
力学是研究物体机械运动和力的作用的科学。力学既是工程科学技术的基础,也是一门
基础的自然科学。力学广泛存在于人的生活、自然现象和各种生产过程中,普及力学知
识,是力学工作者的责任和义务。
科学普及是一切科学活动的目的和归宿。科学活动的成果,一方面是用物质形式上的普
及,改善和丰富了人民的生活,让人民享受科学研究的成果。另一方面在精神上,要较
充分地用科普形式,使因社会分工和知识背景的差异,不了解科学活动的人,也能学习
科学知识,理解科学精神和科学方法,破除迷信,树立科学的世界观。
科学和艺术,是社会物质和精神财富“金币”的两个侧面。她们互相依托和关联,共同
基础都是人类的创造力。历史上,曾经有过科学和艺术相互融会的辉煌年代。后来由于
社会分工越来越细,二者才逐渐分开。文理本来是相通的,只是由于人为的原因,才在
学校的教学中被分割开来。
中国是一个诗词的国度。唐宋诗词是中国文学史上的瑰宝,千百年来一直传诵不衰。过
去人们总是从老子、庄子、墨子等一些思想家的著述中,去寻找古代的力学思想。实际
上,唐宋诗词中也有一些佳句,是古人对力学现象观察的精湛描述
avatar
c*w
3
各位前辈,我是国内在读的硕士,即将毕业,申请的美国学校读PhD,现在收到了一些
offer,想请前辈们帮忙指导一下。
我现在拿到的有两个offer,一个是Vanderbilt University的Interdisciplinary
graduate program in materials science,这个项目第一年是在三个老师的实验室轮
换,第二年起需要在这个学校的任意工科学院中选取两个教授作为共同的导师进行指导
。因为我自己是化学背景的,工科的知识比如模拟,CAD之类的都不懂,数学的功底也
都要差一些,所以实际能选择的老师也不是很多。我大概看了一下,有一个老师(Kane
Jennings)做的是在金属表面的有机薄膜的,用的是自组装或者表面诱导的高分子薄
膜生长。另外有一些做多空硅材料的,纳米晶体光电器件之类的。这些研究可能和我的
背景接近一些。
还有一个是Stony Brook University的化学系,本来化学系的Benjanmin Chu(朱鹏年
)教授,在高分子这块挺强的,但是后来听他组里的学生说,这个教授应该不收学生了
,所以只能在其他方向选了,我看了一下,这个学校的生物化学挺不错的,不过感觉比
较偏理论,比如计算模拟这类的,当然除了生物化学,其他的化学方向也有不错的。
除了这两个学校以外,还有一个就是Georgia Institute of Technology的化学系,可
能有戏,有一个教授(John Reynolds)比较感兴趣,联系过几次,这个教授主要做的
是有机太阳能电池(Organic Photovoltaics)和OLED的,主要都是高分子材料。
因为我自己希望毕业之后能够进公司,最好是能在美国找到工作留下来,所以希望找一
个比较合适进企业的方向。我现在只是在PhDs这个网站上了解到一些信息,好像这三个
学校对应的专业毕业生中,就是Vanderbilt University材料系的学生进公司的多一点
,其他两个化学系的基本是进高校和研究机构了。
但是这个网站的信息毕竟是比较粗犷的,也不太准确,而且绝大多数也只是个统计的结
果。所以我想请教一下各位前辈,不知道您们对于这三个学校和对应的专业是怎么看待
的?要是各位前辈中有人了解的话,想知道一下上面提到的这些具体的研究方向的就业
情况怎么样?各位前辈您要是有其他的建议的话,也麻烦能留言告诉我。我自己实在很
迷茫,很想得到各位前辈您的建议,一定对我有很大的指导作用。
实在很谢谢各位前辈的指导,麻烦您能留言告诉我,或者发我邮箱b******[email protected]
都行,我实在是没法了,太迷茫了,才好不容易翻墙出来咨询各位前辈,谢谢你们~
avatar
r*l
4
This is kinda tricky.
The compile just looks at the declaration to determine the type.
In the IOException example, you know the list can hold "a type" that is IOException's parent class (the exact type is not known). It's ok to add FileNotFoundException since FileNotFoundException is IOException's child, and for sure FileNotFoundException is IOException's parent's child. Without knowing what "a type" is, it's guaranteed that FileNotFoundException is safe to put in the list.
In the Number example, for the same reason, you can add Integer and all its child types to the list (Integer cannot have a child type since it's final). You cannot add any of Integer's parent. Because the compiler just knows the list can hold "a type" that is Integer's parent (or itself), but if you put one of Integer's parent, without knowing what "a type" is, the compiler cannot guarantee that "a type" is compatible with the type you are going to add.

【在 x***n 的大作中提到】
: 请问下面一段代码中,为什么第8行处能compile通过而第14行不行?
: 我的理解是,exceptions 事实上是List (因此所有Exception的子类都可
: 以包含),而numbers事实上就是List,那么14行也理应可以通过才对?
: 1 ArrayList < ? super IOException > exceptions =
: 2 new ArrayList < Exception > ();
: 3 IOException e1 = new IOException("Problem 1");
: 4 IOException e2 = new IOException("Problem 2");
: 5 FileNotFoundException e3 = new FileNotFoundException("Problem 3");
: 6 exceptions.add(e1);
: 7 exceptions.add(e2);

avatar
x*n
6
Many thanks!
So the key is "compiler just looks at the declaration to determine the type"
, and the compiler needs to make sure the element to be added is of the type
surely safe to be added.
So I think that's the same reason why 3 and 4 in the following statements
can't compile:
1 List< ? extends Number> list1 = new ArrayList ();
2 List< ? > list2 = new ArrayList ();
3 list1.add(3.2);
4 list2.add(4.8);

IOException's parent class (the exact type is not known). It's ok to add
FileNotFoundException since FileNotFoundException is IOException's child,
and for sure FileNotFoundException is IOException's parent's child. Without
knowing what "a type" is, it's guaranteed that FileNotFoundException is safe
to put in the list.
its child types to the list (Integer cannot have a child type since it's
final). You cannot add any of Integer's parent. Because the compiler just
knows the list can hold "a type" that is Integer's parent (or itself), but
if you put one of Integer's parent, without knowing what "a type" is, the
compiler cannot guarantee that "a type" is compatible with the type you are
going to add.

【在 r*****l 的大作中提到】
: This is kinda tricky.
: The compile just looks at the declaration to determine the type.
: In the IOException example, you know the list can hold "a type" that is IOException's parent class (the exact type is not known). It's ok to add FileNotFoundException since FileNotFoundException is IOException's child, and for sure FileNotFoundException is IOException's parent's child. Without knowing what "a type" is, it's guaranteed that FileNotFoundException is safe to put in the list.
: In the Number example, for the same reason, you can add Integer and all its child types to the list (Integer cannot have a child type since it's final). You cannot add any of Integer's parent. Because the compiler just knows the list can hold "a type" that is Integer's parent (or itself), but if you put one of Integer's parent, without knowing what "a type" is, the compiler cannot guarantee that "a type" is compatible with the type you are going to add.

avatar
d*e
7
where can I download this?
avatar
r*l
8
Right. If you change "extends Number" to "super Number", then line 3 will
compile.
You can do something like this:
List l1;
List l2 = new ArrayList;
l1 = l2;
l2.add(3.4);

type"
type

【在 x***n 的大作中提到】
: Many thanks!
: So the key is "compiler just looks at the declaration to determine the type"
: , and the compiler needs to make sure the element to be added is of the type
: surely safe to be added.
: So I think that's the same reason why 3 and 4 in the following statements
: can't compile:
: 1 List< ? extends Number> list1 = new ArrayList ();
: 2 List< ? > list2 = new ArrayList ();
: 3 list1.add(3.2);
: 4 list2.add(4.8);

avatar
t*n
9
有书的内容吗

【在 s*****r 的大作中提到】
: 《诗情画意谈力学》序及目录
: 王 振 东
: 力学是研究物体机械运动和力的作用的科学。力学既是工程科学技术的基础,也是一门
: 基础的自然科学。力学广泛存在于人的生活、自然现象和各种生产过程中,普及力学知
: 识,是力学工作者的责任和义务。
: 科学普及是一切科学活动的目的和归宿。科学活动的成果,一方面是用物质形式上的普
: 及,改善和丰富了人民的生活,让人民享受科学研究的成果。另一方面在精神上,要较
: 充分地用科普形式,使因社会分工和知识背景的差异,不了解科学活动的人,也能学习
: 科学知识,理解科学精神和科学方法,破除迷信,树立科学的世界观。
: 科学和艺术,是社会物质和精神财富“金币”的两个侧面。她们互相依托和关联,共同

avatar
x*n
10
Thanks. I see your point. l1 is used as a "readonly" view of l2.

【在 r*****l 的大作中提到】
: Right. If you change "extends Number" to "super Number", then line 3 will
: compile.
: You can do something like this:
: List l1;
: List l2 = new ArrayList;
: l1 = l2;
: l2.add(3.4);
:
: type"
: type

avatar
s*r
11
我不知道哪里有的下载。
博文里面好像有节选内容。
avatar
r*l
12
You have good sense. Actually most of the time and are
for read only use, although you can add null to the collection.

【在 x***n 的大作中提到】
: Thanks. I see your point. l1 is used as a "readonly" view of l2.
avatar
x*n
13
mark
avatar
B*g
14
基础不扎实,看着有点晕

【在 r*****l 的大作中提到】
: You have good sense. Actually most of the time and are
: for read only use, although you can add null to the collection.

avatar
x*n
15
I see. Many thanks!

【在 r*****l 的大作中提到】
: You have good sense. Actually most of the time and are
: for read only use, although you can add null to the collection.

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