Enhanced for loop compiling fine for JDK 8 but not 7

后端 未结 6 1057
Happy的楠姐
Happy的楠姐 2021-01-03 18:36

Consider the following code snippet, I stumpled upon after some refactoring, when checkin why the build server reported a broken build but it was fine in my IDE:

<         


        
6条回答
  •  温柔的废话
    2021-01-03 19:14

    This compiled fine for me. I'm using the Java 8 JDK, on Netbeans, on a 64 bit machine (Windows 7).

    I believe this is a localization issue related to your IDE or compiler. I used your exact example, the output being

    false
    true
    false
    

    There was a warning given, stating that it is possible, but not recommended to hide a field with a local variable.

提交回复
热议问题