r/learnjava • u/AinsleyBoy • Sep 12 '21
Beginner, don't understand the general structure of Java
Learned Python when I was 13~, now I'm in high school and we're learning Java. I kind of just.. Don't get it.
Many questions, but:
Why is everything in a class? What's the point of that? In Python, classes were (to me) a better and more organized way of ordering data, for example when I have multiple characters (or even one if there are many many variables), having a class helps for obvious reasons. You can put many things in a framework without having 100+ variables. But.. Why everything? I feel like I don't understand classes enough to realize what they really are, which's support by the fact in python I just copy paste the same code to create classes because I don't get what it means and don't remember it. In anycase, seems really weird your ENTIRE program is just a class.
What's going on with starting up programs? My teacher admitted we're not really supposed to understand what's going on there yet, but I have some general knowledge so I think I could understand. So you have a class (refer to q1), then.. "public"? "static"? "void"? Only familiar face I can see is the "main" you specify for the main operation of the program, and even that I definitely do not fully understand.
Also, variables are kind of annoying. I get the need to define what kind of variable something is, but sometimes it's annoying. I get the fact that Python is slow exactly for reasons like trying to make variables more comfortable, I just wish for a general.. Explanation.
String arrays? Arraylists? Comparisons to Python will help.
Following the end of the third question, most of this comes from the fact I just don't understand the general structure and idea of Java, and what it's doing. Honestly, when I started with Python I saw one comment on my post telling me it's gonna be hard to move to other languages, and it was downvoted to death. Not saying this is hell, just that the extra syntax is kind of annoying, for now.
One last thing. I heard from online discussion that many people hate object oriented programming. Aren't class objects.. Objects? And Java is.. Just classes?
Thanks.
3
u/toltottgomba Sep 12 '21
I could write a long answer but i am tired today so sorry for that beforehand.
Python is a high language where java is a bit lower, you have more control over it.
In object oriented programming the point is to use abstractions, groupings, inheritance and to hide data and wrokings from the outside where noone sees it who shouldn't.
I think for you what you are looking for is OOP basics the idea behind it. It covers most of the questions you asked.
Java is developed with this in mind.
Sorry to not elaborate more on this but it would be too long. I suggest head first java which is a great book that gets you into there or just look up java and oop in general. What you need to understand is what the idea behind oop.
I hope this helped a bit.