r/learnprogramming • • 19m ago

Topic Confused by intermediate Java

Hi, I'm an IT college student, and i decided to take a Java class that's more advanced, but I can't understand nothing. Im decent with programming languages that are low level, I can use C and Rust, but this stuff looks like rocket science to me, and even with AI im not understanding anything.

It's a class on Java OOP + stuff like Lambdas and Reflection, and every time i try to learn something all I can think is 'why?' and I can't produce an answer.

Do I use get set for everything? When do i abstract instead of using interfaces? Wtf how does a lambda work? Why reflection? Do i private everything? Do i protect everything? Do i static everything? And many others...

Do you have any good book/website or video/course about it? Thanks

0 Upvotes

5 comments sorted by

•

u/MathiasBartl 16m ago

Lambdas are functional, not object oriented.

•

u/dkopgerpgdolfg 14m ago

Wtf how does a lambda work?

Do I use get set for everything?

Do i private everything? Do i protect everything? Do i static everything?

These topics exist for Rust too, which you caim to know. Maybe you need to improve more.

And usually there's no single hard answer. Opinion/style play a role too.

When do i abstract instead of using interfaces?

The difference is a very simply google answer away

Why reflection?

Because it's possible. Why not.

•

u/tin2426 9m ago

For you situation, I can recommend the book Head First Java. It will not cover the language end to end. But, it will give you the intuition that you can use to answer the why's that you are talking about.

Altough, it is not a reference, so it might not be the best material if you want to optimize for performance in your class. But if you want to understand Java, it's a good one.

Another one that you can use is Core Java 1. It's more encyclopedic, and I feel like it might confuse a beginner. But there is that too. Typically, I use it when I need to learn something specific.

Also, the mandatory part, whatever resources you end up using, make sure to apply the knowledge by writing your own programs.

•

u/xarop_pa_toss 3m ago

Ah yes, you have reached the "OOP is bullshit" level. Especially when you know C or Rust like you mentioned, all that added nonsense feels really unnecessary; and to a certain degree it is.

Most people will probably recommend Clean Code by uncle Bob. It became the industry standard book but nowadays a lot of devs think it was a step in the wrong direction.

I use C# instead of Java but it's basically the same thing and the way I got accustomed to it was to actually ignore a lot of features.

  • I almost never use Inheritance. Composition as become the standard I'd say.
  • Interfaces are your friends.
  • Generics are very useful imo. You can write a single parent function that takes any datatype and then you can activate other things according to what was sent in for example.
  • I don't like Lambdas so I don't use them. I understand what they are but I'm confused by them.

What helped make some things click was learning some of the more commonly used Design Patterns. Façade, Factory, Strategy, and others are things you might do naturally in your own code but when you practice them a little bit you'll see that "oh, making this class with different overrides allows me to do X here" for example.

I don't really have a book recommendation on this, except the refactoring.guru website

•

u/Realistic_Speaker_12 3m ago

You might claim to know C and rust but you probably know only the basics. You should get deeper into whatever language you like. Most concepts transfer really well between languages. If you understand C++ to some degree, your intuition for rust and why the language does things in the way it does it is really solid.

To awnser at least one of your questions: a lambda is nothing different than an anonymous class with a function call operator.

It works the same in probably every programming language. In rust you have closures, in c++ you have lambdas, they are lazy evaluated etc..