Skip to content
Advertisement

Tag: oop

Creating multiple objects using the same instance

I just saw this tutorial creating multiple objects using the same instance by applying the DAO pattern and tried it in a simple console, but I always get this message java.lang.NullPointerException I’m now confused, as far as I know, a constructor can be used once only, and the object will be immutable. Kindly look at this: Fighter.java FightersDAO.java Demo.java Why

Why is casting in equals necessary?

I’m doing the Mooc course and it’s teaching us how to compare objects from made up classes like “Person” and see if they are equal to each other. They give us the following code: } For the equals method, I get that they compare using == first to check if it’s the same location. Next they see if the compared

What are transient dependencies?

I am studying the bnd introduction, and it says: ‘The advantage of Java was that it had found an elegant solution to the scourge of transient dependencies: Java interfaces.’ I also found the following quote: in the book ‘Professional Java for Web Applications’, but is there a simpler explanation for transient dependencies that this? Answer It’s not a thing. They

Is it better practice to use static factory methods over an interface implemented by many different objects? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago. Improve this question It seems as though you could either use static factory methods or you can use an interface that many objects implement

Advertisement