search

Home  >  Q&A  >  body text

java foreach和匿名数组的问题

PHP中文网PHP中文网2810 days ago629

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-04-18 10:40:16

    The object traversed must be object, not a basic type. Array types are not classes, but array instances are objects. But in this case, your array has not yet become an instance, so an error is reported.

    reply
    0
  • 黄舟

    黄舟2017-04-18 10:40:16

    The second syntax is incorrect. There is no such way of writing in Java.

    for (int a:new int[] {3,4}) {
        System.out.println(a);
    }

    reply
    0
  • Cancelreply