有没有其他在Java中声明变量的方式?

huangapple 未分类评论56阅读模式
英文:

Is there another way of declaring a variable in java?

问题

以下是翻译好的内容:

我在Java中遇到了这段代码,我认为这段代码不会通过编译,因为变量as没有被声明。但它不仅能够编译通过,而且还成功运行,并且打印出了"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); 
 }

huangapple
  • 本文由 发表于 2020年3月15日 17:14:12
  • 转载请务必保留本文链接:https://java.coder-hub.com/60691336.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定