The “constructor that doesn’t construct” blooper of the day

Two people sent me this code blooper the other day, again, class and parameter names have been changed to protect the identity of the offender(s).

public SomeObject(
boolean lowSetting,
boolean highSetting,
boolean currentSetting,
Color lowColor,
Color highColor,
Color currentColor,
Color otherColor)
{
super();
lowSetting = this.lowSetting;
highSetting = this.highSetting;
[...]

The “I can’t find the object I put in the map” code blooper of the day

This one is fairly easy to catch, but it was a self inflicted code blooper that had me thinking for a bit.

public class Key implements java.io.Serializable
{
String key;

public Key(String key)
{
this.key = key;
}

@Override
public String toString()
{
return [...]

The sad case of the Java object that couldn’t be instantiated in Java

Today’s code blooper involves a Java object that cannot be instantiated in Java.
I was helping somebody unit test some code and we kept getting a null pointer exception on the constructor. First of all, the object in question had overly complicated constructors. Imagine something like this.
public FruitBasket(){
// Does nothing [...]

‘this’ can’t be null

 
This is the first entry on a category I’d like to name “Code bloopers”. I recently got a message about a piece of code that was throwing a null pointer, it was basically of this form:
synchronized(this.foobar)
This is an easy one. If you think it’s because “this” is null, you have to go back to [...]