Very Basic Query on Java Array processing -


trying self teach java here, complete beginner.

im trying select , print multiples of 10 array.

its surely simple if know how?

thanks can give....!

on side note think glass of whiskey might necessary me through learning this??

my (very dodgy) code is:

    //print multiples of 10 in array      double dangermouse[] = { 1,2,4,8,16,32,64,128,256,512 };     double total = 0;      if (total %10 = 0)     {         (double x : dangermouse)         {             total = x;         }     }      system.out.println (total); 

dangermouse

you should stop drinking whisky while coding.

for (int = 0; < dangermouse.length; i++) {     if (dangermouse[i] % 10 == 0) {         system.out.println(dangermouse[i]);     } } 

loop goes through array. if statement checks current array member if multiple of 10. if print , move next element in array , repeat until run out of array.


Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -