英文:
Is there another way of declaring a variable in java?
问题
以下是翻译好的内容:
我在Java中遇到了这段代码,我认为这段代码不会通过编译,因为变量a
和s
没有被声明。但它不仅能够编译通过,而且还成功运行,并且打印出了"5"
。我在这里漏掉了什么?
public static void main(String[] args) {
int j=5;
long h = j++, s, a;
System.out.println(h);
}
英文:
I've come across this piece of code in Java and I thought this wouldn't compile since variables a
and s
are not declared. Not only it compiles but also runs successfully and it prints "5"
. What am I missing here ?
public static void main(String[] args) {
int j=5;
long h = j++, s, a;
System.out.println(h);
}
专注分享java语言的经验与见解,让所有开发者获益!
评论