认识java关键字

takecare 2004-09-10 07:57:11
不管老鸟菜鸟大家都来温习一下这些可能熟悉也可能从来没有用到过的关键字吧。
大家都来条自己能说的说上几句。
如果是引用的话,尤其是本版里曾经讨论过的内容,请顺便将引用的连接也贴上来,方便大家查阅。
以下就是j2sdk1.4版本以前所有的关键字(如果有遗漏提出来有奖哦):
abstract finally public assert float return boolean for short break static byte if strictfp case implements super catch import switch char instanceof synchronized class int this interface throw continue long throws default native transient do new try double package void else private volatile extends protected while final
...全文
1369 46 打赏 收藏 转发到动态 举报
写回复
用AI写文章
46 条回复
切换为时间正序
请发表友善的回复…
发表回复
takecare 2004-09-17
  • 打赏
  • 举报
回复
结了吧。
takecare 2004-09-17
  • 打赏
  • 举报
回复
本来想开贴大家讨论,尤其是挖掘一下这里的FAQ,没有想到这种问题老鸟嗤之以鼻,菜鸟接分。现实世界跟理想的真是相去甚远呀,想不到我这个工作那么多年的人,居然会为这贴子的死的而伤感。
呵呵,这个就是现实吗。只是以前自己作为过客,不当回事情罢了,现在轮到自己做斑竹力图改变一些现状却不得。哈哈。
xueqs 2004-09-15
  • 打赏
  • 举报
回复
mark
vitamines 2004-09-15
  • 打赏
  • 举报
回复
学习
qlampskyface 2004-09-15
  • 打赏
  • 举报
回复
to visteon(Z++):
friendly只是一种表达而已,算不得关键字的
-------------------------------------------


to all:
我先集大成一哈:)
-------------------------------------------
by ntzls(三星堆):
------------------
Const & goto:
------------------
Const and goto are not currently used. They may
be there just in case C++ programmers use them
by mistake to enable the compiler to give a
more meaningful error message.
-------------------------------------------
by moke33(Mr.Li ★ 我爱冰冰):
------------------
transient:
------------------
transient表示在一个序列化类的时候不被序列化,
如密码等敏感的值域可以用transient来修饰
-------------------------------------------
by shangqiao(伤桥):
------------------
volatile:
------------------
做线程时volatile非常重要,用不好可能会影响你的
结果或是效率。当新建一个线程时,为了提高效率,
他会将某些数据考一个备份到自己这里,所以有可能
你在线程中修改了数据,但是修改的只是你自己的备
份而已,而不会影响到原始的数据。如下代码:
public MyThread implements Runnable{
private int flag;
private MyThread(int flag){
this.flag=flag;
}
public void run(){
falg=0;
}
}
那么现在你就修改的是flag的备份,只有在进入和退出
synchronized同步块时同步原始数据,但是使用volatile
这个关键字说明的就是不考备备份,直接使用原始数据,
但是这样又会影响运行效率,所以值得斟酌权衡一下

所以假如两个线程使用同一个flag通信的话,那么就应该注意了
-------------------------------------------
by kingfish(八百里秦川@龙城异客):
------------------
strictfp:
------------------
很少用的一个,使浮点数符合标准
-------------------------------------------
by ntzls(三星堆):
------------------
Assert:
------------------
Assert arrived with JDK 1.4.
-------------------------------------------


我来说两句:
--------------------------------------------------------------
transient

This variable's value won't persist when the object is stored.

将对象存储的时候变量的值不变

这是在对对象序列化的时候起作用,也就是说被声明的变量不会
自动序列化到介质中。通常对实现序列化接口的类中的某些属性
或方法声明。
visteon 2004-09-15
  • 打赏
  • 举报
回复
frend算不算关键字呢?
缺省的类类型都算是frend友元类。

不当之处望指正。
takecare 2004-09-14
  • 打赏
  • 举报
回复
PACKAGE(包):是类或者接口的集合。可以防止命名冲突从而增加的代码的重用性。
shine333 2004-09-13
  • 打赏
  • 举报
回复
我来点另类一点的吧
比如HelloWorld里面除了用到了上面说到的关键字外,还有一些特殊作用的

public class HelloWorld { //空格,{
public static void main(String[] args) { //(, [, ], )
System.out.println("HelloWorld"); //., ", ;
}
} // }
caiyi0903 2004-09-13
  • 打赏
  • 举报
回复
支持
takecare 2004-09-13
  • 打赏
  • 举报
回复
---------------------------------------
ltzperson(玩人大帝):
太乱了,
如果再说明他是干什么用的那就再好不过了,
说来介绍一下
---------------------------------------
本来就是想让大家一起参与的呀。每个人都来说说自己的看法或者用法。
viuncn 2004-09-13
  • 打赏
  • 举报
回复
我是菜鸟,我喜欢...
ltzperson 2004-09-13
  • 打赏
  • 举报
回复
太乱了,
如果再说明他是干什么用的那就再好不过了,
说来介绍一下
mousefog 2004-09-13
  • 打赏
  • 举报
回复
不错,收藏!up!
kingfish 2004-09-13
  • 打赏
  • 举报
回复
strictfp
很少用的一个,使浮点数符合标准
flyingbug 2004-09-12
  • 打赏
  • 举报
回复
good
kkkkwx 2004-09-12
  • 打赏
  • 举报
回复
有心人!
wtobias 2004-09-12
  • 打赏
  • 举报
回复
up
takecare 2004-09-11
  • 打赏
  • 举报
回复
to ntzls(三星堆) :归一下类清楚多了!但是这里是Java基础版,没有办法总得照顾刚入门的新人吧。

我就不btw了。回家睡觉。
ntzls 2004-09-11
  • 打赏
  • 举报
回复
Keywords for data types are:
boolean byte char int long short float double

keywords for access control are:
private protected public

keywords for modifiers are:
abstract final native private protected public
static transient synchronized volatile strictfp

keywords for catch-exception are:
try catch finally throw

keywords for loops or decision-makers are:
break case continue default do while for
switch if else

keywords for class functions are:
class extends implements import instanceof
new package return interface
this throws void super

keywords for assigned values are:
true false null

Assert arrived with JDK 1.4. Const and goto are not currently used. They may be there just in case C++ programmers use them by mistake to enable the compiler to give a more meaningful error message.

板竹贴出来的咋乱的,这样看是不是爽点。^_^
另外注意一下:
1、全小写,类似instanceOf、NULL就不是关键字了。
2、java不会轻易的添加关键字,试想如一下子加入then、sizeof等则原代码中标识符设为then、sizeof的均需更改。所以仔细看好了,就上面几个老熟脸。

BTW:Focus on programming techniques,not on language features。
shangqiao 2004-09-11
  • 打赏
  • 举报
回复
所以假如两个线程使用同一个flag通信的话,那么就应该注意了
加载更多回复(26)

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧