Why does this Java to generate a number multiplication table just repeat the same line? -


below java class of output should have been

>1 2 3 4 5 6 > >2 4 6 8 10 12 > >... > >6 12 18 24 30 36 

but generates 6 lines of:

>2 4 6 8 10 12 

why happen?

public class alterable{     public static void main(string[] args){         int i=1;         while(i<=6){                 printmultiples(i);             i=i+1;         }     }     public static void printmultiples(int n){         int = 1;         while(i<=6){             system.out.print(2*i+" ");             i=i+1;             }         system.out.println("");     }    } 

almost there, forgot user n parameter:

public static void printmultiples(int n){     int = 1;     while(i<=6){         system.out.print(n*i+" ");         i=i+1;     }     system.out.println(""); }  

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -