r/learnjava • • 21h ago

Where can I find documentation that actually describes anything? Dev.java and docs.oracle were not useful.

I am learning using Deitel's book and I wanted to get a deeper understanding of a few concepts. Mainly how some methods work but I can't find a good resource for that. I even read the recommendations thread but I can't find what I want there.

I want something similar to the book where I can see examples and not just some text saying: "This method takes an argument and returns another one" with no deeper explanation.

2 Upvotes

26 comments sorted by

•

u/AutoModerator 21h ago

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions

  • You include any and all error messages in full - best also formatted as code block

  • You ask clear questions

  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

8

u/IHoppo 20h ago

Java docs are fantastic. What are your problems using it?

-2

u/Eva_addict 20h ago

I was trying to learn more about the toString() and what I got there is:

  • toString

  • public String toString()

  • This object (which is already a string!) is itself returned.

  • Specified by: toString in interface CharSequence

  • Overrides: toString in class Object

  • Returns: the string itself.

Wtf is this supposed to help with??

10

u/Lopsided-Dare-8119 20h ago

This is about java.lang.String.toString which does nothing interesting. See java.lang.Integer.toString for something more useful.

9

u/8dot30662386292pow2 20h ago

I don't understand how that does not help you? Seems like you should learn about following concepts:

  1. inheritance

  2. interfaces

  3. polymorphism

  4. method overriding

What is the exact thing you want to learn about toString, maybe I can help?

6

u/IHoppo 20h ago edited 20h ago

Can you help me understand what you don't understand please. To me, that explains everything I'd need to know to use it.

It tells you it's a public method
It tells you what it returns in this implementation.
It tells you where it's specified and what it overrides.

What more do you need?

2

u/onated2 20h ago

Best way to learn java is read the source code.

1

u/istarian 14h ago edited 13h ago

toString() is simply a method that returns a String representation of the class, whatever that happens to mean.

E.g.

Integer num = 5;

String s = num.toString();

s.equals("5") will return true.

If you write your own class then you will also have to write your own implementation of toString or you'll just get the default implementation for Object which is to return the class name followed by '@' and the hashcode of the class instance.

A simple example might be a "data holder object" who toString method merely converts each internal field to it's String representation and concatenates them into one longer string.

P.S.

"hello".toString() just returns itself which makes the function call redundant

-5

u/Moist_Professional64 19h ago

Yeah don’t understand too. I’m learning a different language soon with a better documentation

5

u/IHoppo 18h ago

You're going to be sorely disappointed. Java docs are excellent.

0

u/Moist_Professional64 18h ago

Nah not really good understandable for new people. Many people are confused too

3

u/IHoppo 18h ago

That's a strange statement given absolutely everyone has been a beginner at some stage. What is there that's complicated about the above toString() example?

1

u/Moist_Professional64 18h ago

You can read what op is writing here. Same too me what he’s writing

3

u/IHoppo 18h ago

I've asked OP and they haven't responded since giving the example. You can see my response above https://www.reddit.com/r/learnjava/s/Fq7D5nokEw - can you give me something which you don't understand please and I'll try to help?

-1

u/Moist_Professional64 18h ago

How would you describe something that you can’t completely understand. That dosent work

5

u/IHoppo 18h ago

Mate, if you want to become a coder but you can't tell me what you don't understand you've got a world of pain ahead of you. Good luck!

→ More replies (0)

4

u/Automatic-Gur2046 20h ago

Horstmann core java

5

u/aqua_regis 20h ago

Mainly how some methods work

Java is open source. Just look at the source code.

1

u/RevolutionaryRush717 13h ago

Underrated comment.

1

u/cainhurstcat 20h ago

I fetch things on Kagi with "two dimensional array examples java", or what ever concept you want to learn. Also "best practice" instead of "example"

1

u/poxramona 5h ago

Java language specification : https://docs.oracle.com/javase/specs/

Java tutorial : https://docs.oracle.com/javase/tutorial/

Java API documentation : https://docs.oracle.com/en/java/javase/21/docs/api/

And the Java API source code is mostly written in Java, and is very readable.

Then there are some good books. Hortsman's Core Java for instance. There are more specialized books when needed.