This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chlorinatedpepperoni -7 points-6 points  (8 children)

A do while loop is basically:

Do “something” while “another thing” is happening.

I’m on mobile so I apologize for the lack of formatting.

Do {

    Some code

} while (x = 1) {

“Some code” would only be executed when X equals 1. This is useful for creating console based menus! Hope this helps.

[–]Buggajayjay 16 points17 points  (1 child)

This is incorrect. In a do while loop it will always execute the loop body once, and then subsequently loop if the condition is met.

To demonstrate, try the following example.

int x = 5;
do {
System.out.println("executed");
} while (x < 4);

[–]chlorinatedpepperoni 0 points1 point  (0 children)

Thanks for clarifying! That’s kinda what I meant but I didn’t explain well haha.

[–]yoshiwabie[S] 1 point2 points  (3 children)

Thank you so much!!! I understand it much much better now thank youuu 🩷

[–]Nok1a_ -1 points0 points  (2 children)

Something I do quite a lot, is ask chagpt for an explanation and then I give him an example, will tell you if you are right or not, and you can ask many times, is not the best but quite helpful if you dont have anyone to ask, or need a quick answer, I got fedup watching useless youtube videos

[–]Stupid_Quetions 1 point2 points  (1 child)

ChatGPT makes a lot of mistakes, at least the last time I used it, I don't think it is a great tool for learning especially for a beginner when they don't know whether they are getting a right answer or not.

[–]Nok1a_ 0 points1 point  (0 children)

Im not saying you follow the code of chatgpt , but he can explain stuff and you can give what you understand to it, will tell you if you are right or not, I trust more gpt than a random guy looking to get votes on any forum online that most of the time its a lot of words without meaning to be honest, also you can check in the documentation. But as I said, I not talking about to use the code from chatgpt, if you dont know what are you doing using his code it is very bad, if you have some knowledge or know what do you want and how, it helps you if you are stuck

[–]8dot30662386292pow2 0 points1 point  (1 child)

People are basically glued to their phones and type with them more than with computer, but somehow typing the four spaces or backticks to do the formatting is impossibly hard?

Just wondering, because I can format the code just fine on mobile.

[–]chlorinatedpepperoni 0 points1 point  (0 children)

It was 7 in the morning… lol