new*_*bie 0 java parameters methods field local-variables
以下类中每个表达式的术语是什么:
例如:
class Test {
int a=0;
void method(boolean boo){
String b="";
try
{
new Thread().sleep(1000);
}
catch(InterruptedException e){}
JOptionPane.showMessageDialog(null,"test");
BufferedImage image=ImageIO.read(new File("C:\\file.png"));
}
}
Run Code Online (Sandbox Code Playgroud)
从我所知道的a
是一个字段,boo
是一个参数,b
并且image
是局部变量.
用于什么术语
new Thread().sleep()
JOptionPane.showMessageDialog()
ImageIO.read()
new File()
InterruptedException
new Thread()
是一个构造函数调用.您正在立即调用sleep
该实例.这很奇怪,因为它sleep
是一个静态方法,所以你可以做Thread.sleep(1000)
一个静态调用(确保捕获和处理InterruptedException
.
JOptionPane.showMessageDialog()
是一个静态方法调用ImageIO.read()
.new File()
是一个返回File
对象的构造函数调用.
关于命名约定的一句话:字段名称(不是static final
常量),变量名称和方法名称应该是camelCase
类名称PascalCase
.