"Second, if you declare constructors, what you see is what you get. This means that if you don't explicitly declare a no-arguments constructor but declare some other constructor, you will only get the constructor that you do explicitly define. This is why you see an error in example 3. Since you've never declared a no-arguments constructor but did define another type of constructor, Java does not insert a no-arguments constructor."
"Editor's note: Sometimes the most interesting discussions begin when someone says, "This may be a stupid question, but ...." If the person asking the question has taken the time to think about the problem before asking, the question is often not stupid at all. The uncertainty points out an ambiguity in the specs, holes in the docs, or a search for how more experienced programmers might address a particular problem. From time to time, we will print one of the "(Not So) Stupid Questions" we receive and invite our readers to answer the question in the feedback section."
"Editor's note: Sometimes the most interesting discussions begin when someone says, "This may be a stupid question, but ...." If the person asking the question has taken the time to think about the problem before asking, the question is often not stupid at all. The uncertainty points out an ambiguity in the specs, holes in the docs, or a search for how more experienced programmers might address a particular problem. From time to time, we will print one of the "(Not So) Stupid Questions" we receive and invite our readers to answer the question in the feedback section."
"In the last column Object Construction, I began a discussion about constructors. Designing effective constructors is one of the responsibilities that must be taken care of when creating classes. In the previous column, I covered constructor basics as well as some finer points of constructor design. Remember that proper construction puts the object in a safe-state. In this article, you will delve deeper into code as you uncover many of the implementation issues of designing constructors."
"A second advantage of static factory methods is that, unlike constructors, they are not required to create a new object each time they’re invoked. This allows immutable classes (Item 15) to use preconstructed instances, or to cache instances as they’re constructed, and dispense them repeatedly to avoid creating unnecessary duplicate objects. The Boolean.valueOf(boolean) method illustrates this technique: it never creates an object. This technique is similar to the Flyweight pattern [Gamma95, p. 195]. It can greatly improve performance if equivalent objects are requested often, especially if they are expensive to create."
"Every programming language has its own special wrinkles, and knowledge of these can help in rapidly solving specific problems. In this article, I'll look at three areas of Java that often pass under the radar of programmers: copy constructors, cloning, and linked structures. Not fully understanding these areas of Java can result in reduced modularity and weak encapsulation—for example, not using copy constructors can easily result in unnecessary object instantiations. The same is true for cloning. Likewise, not using linked data structures can make for an unnecessarily complex data model."