Traversing 2D Arrays

AP Computer Science A· difficulty 4/5

Doubling each element of m:

  • A

    Cannot modify

  • B

    Use indexed loops: for(i...) for(j...) m[i][j] *= 2;

    check_circle
  • C

    Use stream()

  • D

    Use enhanced-for (modifies)

Explanation

Enhanced-for gives copies (for primitives); use indexed loops for modification.

Want 10 more like this — adaptive to your weak spots?

Related questions