0
My first steps with Java. Is there an error in this code?
Hello community! This is my first post ever and I'm gonna ask, should someone have the time, a question regarding an extremely basic thing on Java. I can't figure it out. What's wrong with these lines? public class ej5{ public static void main(String[] args){ int nFinal=37; procBucle(nFinal); } public static void procBucle(int nFinal){ for(int i=0;i<nFinal;i++){ System.out.println(i); } return i; } } Thank you so much.
3 Respostas
0
remove this line...
return i;
You define your method with "void" which means it doesn't return anything.. Also, you attempt to return i, which is only a variable inside of your for loop, and your trying to use it outside of said loop
+ 1
Thank you so much! That was my first exercise ever. Appreciated Rick
0
No problem. keep it up!