java关键字
相关文章:
Java中的transient,volatile和strictfp关键字
Java 关键字
多核线程笔记-volatile原理与技巧
推荐圈子: D语言
更多相关推荐 Java关键字(keywords)
abstract default if private this
boolean do implements protected throw
break double import public throws
byte else instanceof return transient
case extends int short try
catch final interface static void
char finally long strictfp volatile
class float native super while
const for new switch
continue goto package synchronized
以上是java specifications中定义的keywords,一共48个,其中常见的三个看似是关键字的true, false, null,都不是关键字,而是作为一个单独标识类型。
其中,不常用到的关键字有:const,goto,native,strictfp,transient,volatile。
const和goto为java中的保留字。
1. native
native是方法修饰符。Native方法是由另外一种语言(如c/c++,FORTRAN,汇编)实现的本地方法。因为在外部实现了方法,所以在java代码中,就不需要声明了,有点类似于借口方法。Native可以和其他一些修饰符连用,但是abstract方法和Interface方法不能用native来修饰。
Example:
Java代码
public interface TestInterface {
void doMethod();
}
public class Test implements TestInterface {
public native void doMethod();
private native int doMethodB();
public native synchronized String doMethodC();
static native void doMethodD();
}
public interface TestInterface {
void doMethod();
}
public class Test implements TestInterface {
public native void doMethod();
private native int doMethodB();
public native synchronized String doMethodC();
static native void doMethodD();
}
为什么需要使用native method?请参考:
doc.guandang.net java Native Method初涉
2. strictfp
修饰类和方法,意思是FP-strict,精确浮点,符合IEEE-754规范的。当一个class或interface用strictfp声明,内部所有的float和double表达式都会成为strictfp的。Interface method不能被声明为strictfp的,class的可以。
Example:
Java代码
strictfp interface FPTest {
void methodA();
}
class FPClass implements FPTest {
public void methodA() {
}
public void methodB() {
}
public strictfp void methodC() {
}
}
class FPClassB {
strictfp void methodA() {
}
}
strictfp interface FPTest {
void methodA();
}
class FPClass implements FPTest {
public void methodA() {
}
public void methodB() {
}
public strictfp void method
JAVA 常用关键字汇总序 关键字 号 1 2 3 4 5 6 7 abstract boolean break byte case catch char [ [ [ [ [ [ [ ] ] ] ] ] ] ] 抽象 布尔类型...
java关键字_工学_高等教育_教育专区。JAVA 关键字名称:public 解释:访问权限修饰符的一种,公开,公共的意思。 用法:用来修饰类,属性,方法。对于外部的任何类都...
Abstract 抽象的 一个 Java 语言中的关键字,用在类的声明中来指明一个类是不能被实例化 的,但是可以被其它类继承。一个抽象类可以使用抽象方法,抽象方法不需要...
Java 中的所有整数值都是 32 位的 int 值,除非值后面有 l 或 L(如 235L) , 这表示该值应解释为 long。 25.interface interface 关键字用来声明新的 Java...
java关键字_计算机软件及应用_IT/计算机_专业资料。java关键字Static 修饰符 1.static修饰的方法叫静态方法 public static void main(String args[]){} 2....
java 中的 50 个关键字和关键字的意思 Abstract 抽象的 一个 Java 语言中的关键字,用在类的声明中来指明一个类是不能被实例化的, 但是可以被其它类继承。一...
java关键字_IT/计算机_专业资料。Java 关键字 速查表访问控制: private 私有的 protected 受保护的 public 公共的 类、方法和变量修饰符 abstract 声明抽象 class...
对java的关键字进行详尽的分析,对于想要在java的学习道路上更上一层楼的同学来说,掌握java关键字的用法是非常有必要的。对java的关键字进行详尽的分析,对于想要在...
Java关键字(keywords)_计算机软件及应用_IT/计算机_专业资料。Java关键字Java 关键字(keywords) ) abstract default boolean do break double byte else case ...
热门文档