找回密码
 FreeOZ用户注册
查看: 1430|回复: 7
打印 上一主题 下一主题

[论坛技术] 请教两个Java基本概念的辩析

[复制链接]
跳转到指定楼层
1#
发表于 21-6-2009 10:32:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?FreeOZ用户注册

x
Inner class / Nested class
Keyword / Reserved word

对于Inner class / Nested class,我个人觉得应该是对应嵌套的类
是否static而言吧?非static的为inner,static的为nested。

我一直以为keyword和reserved word是没有区别的。但想一下,比如goto是reserved word,
但应该不是keyword。昨天看到一个问题,就是null是否keyword,是否reserved word,
我就有点晕了。
回复  

使用道具 举报

2#
发表于 21-6-2009 16:46:55 | 只看该作者
对这两个问题都不清楚,因为一直都是实用主义,不会十分计较些微的区别,例如keyword vs. reserved keyword,这大概是写编译器或者考试才会关心的吧。
关于inner/nested class,我觉得不是是否有static的区别吧,倒是要注意是否与static关系到是否有个隐含的内部指针,这在某些情况下区别很大,甚至会造成内存泄露。
回复  

使用道具 举报

3#
发表于 21-6-2009 17:14:10 | 只看该作者
Terminology: Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.
所以inner class是nested class的一个特例。

Reserved identifiers include keywords, two Boolean literals (true, false) , and the null literal.
所以keyword是reserved word的子集。
回到你的问题,null 是reserved word,不是keyword。
goto是keyword,也是reserved word。

[ 本帖最后由 felix100 于 21-6-2009 16:25 编辑 ]

评分

参与人数 1威望 +20 收起 理由
key + 20 非常感谢你的帮助!

查看全部评分

回复  

使用道具 举报

4#
发表于 22-6-2009 15:10:33 | 只看该作者

回复 #3 felix100 的帖子

果然是专家。。。
受用了。。。
回复  

使用道具 举报

5#
 楼主| 发表于 22-6-2009 18:27:31 | 只看该作者
原帖由 felix100 于 21-6-2009 16:14 发表 [url=http://www.freeoz.org/forum/redirect.php?Terminology: Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes.
所以inner class是nested class的一个特例。

Thank u... 今天看书认实了这个。

Reserved identifiers include keywords, two Boolean literals (true, false) , and the null literal.
所以keyword是reserved word的子集。
回到你的问题,null 是reserved word,不是keyword。
goto是keyword,也是reserved word。


我那本书把reserved identifiers和keyword等同了,看来真正的reserved identifier = keyword + 3.
谢谢!
回复  

使用道具 举报

6#
发表于 22-6-2009 19:53:18 | 只看该作者
key在准备考SCJD?
回复  

使用道具 举报

7#
发表于 22-6-2009 20:24:04 | 只看该作者

回复 #6 ritz 的帖子

借道问一下,考SCJD需要SCJP吗?
小弟的SCJP是2000年的,不知道有没有过期之说。。。
听说OZ那边java机会多点,正在考虑是否要重新拾起忘记得差不多的java。。。
回复  

使用道具 举报

8#
 楼主| 发表于 22-6-2009 20:31:07 | 只看该作者

评分

参与人数 2威望 +40 收起 理由
coredump + 30 你太有才了!
ritz + 10 你太有才了! 老乞丐还有更多花样的 :P

查看全部评分

回复  

使用道具 举报

您需要登录后才可以回帖 登录 | FreeOZ用户注册

本版积分规则

小黑屋|手机版|Archiver|FreeOZ论坛

GMT+11, 2-4-2025 12:47 , Processed in 0.040023 second(s), 25 queries , Gzip On, Redis On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表