r/learnprogramming • • 21d ago

Suggestions regarding programming

I'm 18. I'm currently learning Java and I feel I'm unable to understand stuff in it, especially object oriented programming. The practice feels like I'm falling behind.

16 Upvotes

39 comments sorted by

View all comments

1

u/Sad_Quote1522 21d ago

Are you self taught or is this a instructor led course? It's likely you are better off grinding out more basic stuff before jumping back into OOP.  I don't know Java so hopefully these aren't too confusing.  Before OOP you should be proficient with(in a loose easy -> hard order:

How to create and modify variables

If statements

Loops(for/while)

Comparison statements 

How to write a basic program

Understanding types

How to write a function and utilize it in your main function

Understanding scope

None of this is too crazy but without this bit of foundation OOP becomes a confusing black box of nonsense.  

OOP super boiled down is just the idea that you can define a class in any way you want.  If I was designing a class for "Ball" it might have variables like weight, size, material, and bounceyness.  I can then think up different types of "Ball": Soccer ball, Bowling ball, baseball.  Each of these I could make as an object with their own set of the variables above to describe them.  When I use them in my code, I can easily and systematically create different "Ball" objects without having a huge mess of unorganized variables and functions.  

If you didn't have a class "Ball" and you wanted to add a new variable to each ball in your program it would be a lot of work.  With OOP you just would add it to the "Ball" class and all the objects made during runtime would automatically have it.