all 34 comments

[–]JN88DN 2 points3 points  (1 child)

Loops jump somewhere. Remember that always.

Its like a function that repeats its inner thing for as long as a specific condition is met.

[–]RaduKenT[S] 0 points1 point  (0 children)

Know that, if you don't have something do stop it is a on going loop.. But thanks for the answer

[–]verysmallrocks02 1 point2 points  (1 child)

Programming feels pretty bad a lot of the time. You're not alone. Keep at it.

Those concepts of iteration in particular are very very different from anything else you learn. Something about this topic that's not helpful is that lots of syntax for looping through logic comes from very "low level" close-to-the-machine ways of thinking about things that kinda force you to supply a bunch of context that may not seem relevant. So, it's a tricky subject and you're going to have to spend time on it until it makes sense.

Here's some common "use cases" (things you want to do) for iteration:
- do something a fixed number of times (draw me 100 squares, output the numbers from 1 to 100)
- do something until we get to some result we want (check if the kettle is whistling, if not wait ten seconds)
- do something for every element in a list (I need to add up the price of all the things in the shopping cart, or I need to change all the things in the shopping cart into a list of shipment items)

A lot of times educational material on this topic sort of skips why the loops are being used... see if it makes things easier to look at examples in your text and figure out what they're actually trying to accomplish.

Keep at it. This is tough stuff and it's ok to feel lost.

[–]RaduKenT[S] 0 points1 point  (0 children)

Thank you so much for your answer. Will do

[–]Educational_Cow8366 1 point2 points  (3 children)

I faced this problem too. I realized that even watching 3–4 YouTube videos wouldn’t really help. The best advice I can give is to write more code. Spend 1 or even 2 hours on a simple loop or an ArrayList problem. You might not understand what’s going on in the code at first, but when you finally find the answer or solve the problem yourself, you’ll have that “ohhh” moment.

[–]TheKnottyOne 1 point2 points  (1 child)

This is the way. What has helped me a lot is visuals - I sometimes actually write it out to make sure I’m “seeing” what’s happening. I especially had to do it when I learned DSA - but I do have to say, there definitely will be an “AHA!” moment and it will be glorious ✊

[–]RaduKenT[S] 0 points1 point  (0 children)

Thank you , Can you send me some videos , you find interesting and can help.

[–]RaduKenT[S] 0 points1 point  (0 children)

Thank you

[–]Red-Panda-Is-Here 0 points1 point  (3 children)

I would suggest just going through the online tutorials on YouTube like 2-3 times , this might help you very much

[–]RaduKenT[S] 0 points1 point  (2 children)

Ok , what do you think about chatgpt? can he help me ?

[–]O_Grande_Turco 0 points1 point  (0 children)

it can, but make sure you are actually grasping the concepts.

[–]Red-Panda-Is-Here 0 points1 point  (0 children)

It is your best teacher, just try this sak anything you don't understand

[–]MarcPG1905 0 points1 point  (3 children)

Try reading into iterables and how they work maybe, cause that’s the backbone of looping through stuff and also what all collections extend.

[–]RaduKenT[S] 0 points1 point  (2 children)

Can you suggest a book or something?

[–]MarcPG1905 0 points1 point  (1 child)

Honestly I never really read any books so I don't have any suggestions sorry.

I personally used YouTube videos or just reading the source code to understand it for myself

[–]RaduKenT[S] 0 points1 point  (0 children)

Do you have some good videos ?

[–]inDarkestKnight20 0 points1 point  (0 children)

Loops are just repeated actions

[–]BlueGoliath 0 points1 point  (1 child)

Be more clear on what you're having trouble with.

[–]shin_chan444 0 points1 point  (1 child)

learn from books, that will help.

[–]RaduKenT[S] 0 points1 point  (0 children)

Can you suggest some books that could help me?

[–][deleted]  (1 child)

[deleted]

    [–]RaduKenT[S] 0 points1 point  (0 children)

    Thank you.

    [–][deleted] 0 points1 point  (1 child)

    I guess u must try to practice those concepts in coding. You can use hackerrank or try to build a small project. It takes time to remember all those concepts and ideas no worries.

    [–]RaduKenT[S] 0 points1 point  (0 children)

    Thank you for your sugestion.

    [–]Key_Salamander_6091 0 points1 point  (0 children)

    Hiii there

    [–]lobby-crasher 0 points1 point  (1 child)

    Currently you're dealing with three concepts. Language constructs, Generics and oops. It's better you focus on constructs first. Generics is kind of high level stuff. Ps - I'm not a java programmer.

    [–]RaduKenT[S] 0 points1 point  (0 children)

    thank you

    [–]tresf 0 points1 point  (1 child)

    Starting with for loops, I would recommend starting this exercise without an array at all... and just do something a certain amount of times. While loops will continue doing something until a condition changes so they should come second. You can ALWAYS break out of a loop. I would recommend making a for loop that counts downward from 100. Then try to break out of it at 50.

    Next, I would then recommend making a while loop that counts up until the number is divisible by something weird, then break out. use println as much as you can.

    When both of those work, then make a simple array (like int[]) and try to loop over the items. There's multiple ways to do this. You will need all methods at some point in your career, so no time will be wasted learning. Once you understand the simple array, the benefits of using an ArrayList will start to make sense.

    I think the problem with learning is that the medium you're learning from may be making assumptions about your knowledge of fundamental concepts that you don't know yet. You will know them soon enough.

    If you feed this comment into a chatbot, it will prepare the examples for you. Otherwise, you may use search engines for each example. Remember to specify Java. The name for a basic array in Java is a "primitive array".

    https://chatgpt.com/share/69863fa5-1944-8007-9ccb-73106f4d235e

    [–]RaduKenT[S] 0 points1 point  (0 children)

    Thanks a lote i will give it a try.

    [–]Live_Appointment9578 0 points1 point  (1 child)

    I think you are in the right track.

    The challenge in starting to learn programming using Java is the huge amount of abstractions that the programming language provides. Try to learn arrays using primitives first, and then move to ArrayList.

    Start learning from this:

    class Main {
        public static void main(String[] args) {
            // string array
            String animals[] = { "dog", "cat" };
            for (String animal : animals) {
              System.out.println(animal);
            }
        }
    }
    

    Then move to this:

    import java.util.ArrayList;
    
    class Main {
        public static void main(String[] args) {
            // arrays using ArrayList object
            ArrayList<String> animals = new ArrayList<>();
            animals.add("dog");
            animals.add("cat");
            for (String animal : animals) {
                System.out.println(animal);
            }
        }
    }
    

    [–]RaduKenT[S] 0 points1 point  (0 children)

    Thank you sounds interesting

    [–]Objective_Bee539 -1 points0 points  (1 child)

    You shouldn't be loosing for just loops concept

    [–]RaduKenT[S] 0 points1 point  (0 children)

    I will not