简体   繁体   中英

Trouble printing a for loop in a page

I'm currently trying to print the result of a for loop located in a servlet onto a web page, however, for some reason, despite the for being correctly structured, it is only printing the first instance/result.

    private int[] tabla (String Numero){
               
        int[] resultado = new int [12];   
            for(int i = 0; i <= resultado.length; i++)
            {
  
                resultado[i]=Integer.parseInt(Numero)*i;
                
            }
    return resultado;
    }

What am I doing wrong? Is the for being interrupted for some reason?

Remove the = from the for loop for(int i = 0; i < resultado.length; i++)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM