Java: “Anonymous” array in for-each-loop

后端 未结 4 1116
感动是毒
感动是毒 2021-01-01 08:52

While I was trying something special in for loop I recognized that Java doesn\'t seem to like putting an anonymous array right as the source for a for-each-loop:

<         


        
4条回答
  •  忘掉有多难
    2021-01-01 09:45

    Dunno, what about this? :) Pity there's no succinct version. Suppose you could use Groovy or Scala if you wanted anything like that :)

    for (String s : Arrays.asList("a","b","c")) {
        hmm(s);
    }
    

提交回复
热议问题