how can i modifty this code to print the following sequence?

Manuel Buenrostro
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?

sprinter

Change your assignment line to:

myNums[i] = i % 2;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how can I make the following code better?

From Dev

How can I sort the following sequence of strings in c++?

From Dev

how to print the ip in the following code?

From Dev

How can I print out a matrix in the following format in prolog

From Dev

How can I literally print out an escape sequence in python?

From Dev

How can I print the first result of a search sequence for each iteration?

From Dev

How can I optimize this code to print in this format?

From Dev

How can I print well formatted code

From Dev

How can I reduce the following code in single line 'for' loop

From Dev

How can I pass arguments to the function pointer in following code?

From Dev

how can i use function in $message statement in the following code

From Dev

How can I convert a Mat_ to Mat in the following code?

From Dev

How can I write the following Javascript code snippet better?

From Dev

how can I get this a tag to go to the link exluding the following code

From Dev

How can I add onClick and onLongClick in the following code

From Dev

How can I write the following octave code without a for loop?

From Dev

How can i fix the following Python code freeze issue?

From Dev

How can the following code be simplified

From Dev

How can I control the sequence of the code execution in protractor

From Dev

How can I get this code to make the sequence obvious?

From Dev

How can I stop my Collatz Sequence code at 1?

From Dev

How can I change my following quick sort code so that I can use randomized pivot?

From Dev

How can I modify following ps command to print in comma separated value (CSV) format?

From Dev

Can I have, using AngularJS ($http), the following call sequence?

From Dev

i can't understand these following code

From Dev

How can I print this?

From Dev

How can i calculate the response time in the below code and print it on the console

From Dev

how can I print ascii code value in c++ in this way?

From Dev

How can I define argv[2] to be a list as per the following code, and can be called at runtime?

Related Related

  1. 1

    how can I make the following code better?

  2. 2

    How can I sort the following sequence of strings in c++?

  3. 3

    how to print the ip in the following code?

  4. 4

    How can I print out a matrix in the following format in prolog

  5. 5

    How can I literally print out an escape sequence in python?

  6. 6

    How can I print the first result of a search sequence for each iteration?

  7. 7

    How can I optimize this code to print in this format?

  8. 8

    How can I print well formatted code

  9. 9

    How can I reduce the following code in single line 'for' loop

  10. 10

    How can I pass arguments to the function pointer in following code?

  11. 11

    how can i use function in $message statement in the following code

  12. 12

    How can I convert a Mat_ to Mat in the following code?

  13. 13

    How can I write the following Javascript code snippet better?

  14. 14

    how can I get this a tag to go to the link exluding the following code

  15. 15

    How can I add onClick and onLongClick in the following code

  16. 16

    How can I write the following octave code without a for loop?

  17. 17

    How can i fix the following Python code freeze issue?

  18. 18

    How can the following code be simplified

  19. 19

    How can I control the sequence of the code execution in protractor

  20. 20

    How can I get this code to make the sequence obvious?

  21. 21

    How can I stop my Collatz Sequence code at 1?

  22. 22

    How can I change my following quick sort code so that I can use randomized pivot?

  23. 23

    How can I modify following ps command to print in comma separated value (CSV) format?

  24. 24

    Can I have, using AngularJS ($http), the following call sequence?

  25. 25

    i can't understand these following code

  26. 26

    How can I print this?

  27. 27

    How can i calculate the response time in the below code and print it on the console

  28. 28

    how can I print ascii code value in c++ in this way?

  29. 29

    How can I define argv[2] to be a list as per the following code, and can be called at runtime?

HotTag

Archive