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;
[...]
Filed under: Code Bloopers on February 15th, 2008 | 3 Comments »
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 [...]
Filed under: Code Bloopers on October 17th, 2007 | 1 Comment »
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 [...]
Filed under: Code Bloopers on May 4th, 2007 | No Comments »
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 [...]
Filed under: Code Bloopers, Java, Software Development on January 19th, 2007 | No Comments »