-3
public class ArrayR71A
{
  public static void main(String [] args)
  {

      int[] myNums = new int[10];

      for (int i = 0; i < myNums.length; i++)
      {
          myNums[i] = i + 1;
          System.out.print(myNums[i] + " ");
      }

  }
}

it currently prints out 1 2 3 4 5 6 7 8 9 10, but what would be the quickest way to modify it to print the sequence 0 1 0 1 0 1 0 1 0 1?

Manuel Buenrostro
  • 121
  • 1
  • 2
  • 5
  • 1
    This question violates most of the guidelines for what makes up a good question: http://stackoverflow.com/help/how-to-ask So don't feel bad about the down votes, it's just the immune system of stackoverflow trying to discourage you from adding harmful artifacts to the site which have no benefit for others, and only benefits you. – Eric Leschinski Feb 06 '15 at 21:46

1 Answers1

0

Change your assignment line to:

myNums[i] = i % 2;
sprinter
  • 27,148
  • 6
  • 47
  • 78