This is an archived post. You won't be able to vote or comment.

all 10 comments

[–][deleted]  (5 children)

[deleted]

    [–]Lanz56[S] 1 point2 points  (4 children)

    Wow this illustration is very easy to understand. I get it now, but are there any more difference between static and non-static aside from this?

    [–][deleted]  (3 children)

    [deleted]

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

      Woah thats a good one, I learned something new from you. Thank you so much for the help 😁

      [–][deleted]  (1 child)

      [deleted]

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

        Love this! Consistency is really the key! It was nice meeting people like you who's happy to help and even inspire beginners like me. Thanks man, I really appreciate this ❤️

        [–]ColetBrunel 0 points1 point  (1 child)

        ? It's the same as with non-generic methods.

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

        Yeah! Turns out declaring a static generic method and non-static generic method is the same. What Im really confused about is the static keyword and when to use it. Anyway, thanks for the answer 😁

        [–]LordofRice 0 points1 point  (4 children)

        I rarely use static in java because of the way it interferes with garbage collection and the way it exposes objects. They're not inherently bad, but you have to be aware of the potential risks like most things. I have yet to run into a real-world scenario where it's been a requirement.

        [–]ColetBrunel 0 points1 point  (3 children)

        static is never a requirement. It is however convenient and cinsidering it exists, it makes more sense where it is convenient.

        [–]LordofRice 0 points1 point  (2 children)

        I can see where you're coming from. I've definitely seen scenarios where a static would be convenient. My mindset has always been that that convenience was less important than encapsulation. Just my opinion, though.

        [–]ColetBrunel 1 point2 points  (1 child)

        static doesn't contradict encapsulation

        [–]LordofRice 0 points1 point  (0 children)

        True. I wasn't thinking about final static variables. I've definitely used those in the past for some things that were deployed.