I was trying this question saying to write a function that generated cubes between S and
N. Could anyone just explain what I done wrongl tried my best with this question and took my time with it. I was guessing it was nested for loops but then I failed with trying to make it work. Now I only left it as one loop and tried to make sense of it but then its asking me to return a String since thats the return type of the method. Any help I would be thankful
#Beginner Java question
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
why do you set S = 0?
you should introduce a loop variable that starts at S
also you need to accumulate the results
mind sharing the error message with us? humans are bad compilers and i cant spot the issue right away
and not return in the first loop cycle
else is unnecessary here btw
oh, ur missing a return in all cases
You are early enough in your journey that it might be worth it to learn things a bit more deeply
For learning Java, we recommend the ebook Modern Java:
https://javabook.mccue.dev/
It is completely free, meant for beginners and covers all content relevant for the first year. It is a great way to learn Java from the ground up.
If you run into any questions during your journey, you may ask us in #1051826284008853505 and we will help 
If you prefer a more traditional learning experience, we also recommend MOOC:
https://java-programming.mooc.fi/
This is the course used by the University of Helsinki to teach their students programming in their first year, also completely free.
emccue • used /tag id: learn
·
Yhh I done that before I set i = S but I kept on getting an error saying i is unspecified
int i = S;
Ok ill open it again
why did u set the S in the for loop? or why did u set it out of it?
Also strong recommendation to not use AI at all
why do you return if S is smaller than 0 when u set it to 0 anyways?
True but is it ok if I use it to generate me practice questions for my programming exam
No
Oh
Like okay let me justify that
You are currently not at the point where what you need is practice problems
You have a weak understanding of both mechanics and how to write software
Hmm ur right
And in general AI is playing with fire. There are practice problems out there when you need them
if you are using an integer in a for loop, you can define it within the for loop, and absolutely no need to define it outside the class. make it into a local variable instead
Is the for loop okay now
no
No
you return after the first cycle
Also there is the snipping tool for taking screenshots
so the loop does not loop
You don't need to use your phone
also i = S, not 0, you want the first cube to be S
Yes yes
Genuine advice is to stop and go back to basics
Alright brother
You aren't ready for this problem yet
Ill revise loops again
For learning Java, we recommend the ebook Modern Java:
https://javabook.mccue.dev/
It is completely free, meant for beginners and covers all content relevant for the first year. It is a great way to learn Java from the ground up.
If you run into any questions during your journey, you may ask us in #1051826284008853505 and we will help 
If you prefer a more traditional learning experience, we also recommend MOOC:
https://java-programming.mooc.fi/
This is the course used by the University of Helsinki to teach their students programming in their first year, also completely free.
emccue • used /tag id: learn
·
Thankz
good tut
tells the basics (syntax, logic, etc.)
Why is it Minecraft tho
dont matter
I am biased because I wrote it, but use that first link I sent
Cool
Book teaching how to write modern and effective Java.
And genuinely go from the start
Definitely
I'm not as biased, but I'd also recommend that path (having clicked through two or three of those videos).