Help with arrays and null pointer assignments!!
Could someone please be kind enough to tell me what I am doing wrong here.
I have been racking my brain for a few days now and I just don't understand
where the problem comes from.
Bassically I have a class that I'm using to keep some static variables in.
The constuctor gets called and the variables are initialized in the right
way. However, when I recall them with my getter, it's as if the get methode
has lost all track of them(the variables), and I get a null pointer assignment
Here Is my storage class:
public class ColumnValues
private static final int MAX_COLS = 4; //
private static int colValue;
private static int maxValue;
int colValue = new int[MAX_COLS];
colValue = 10;
colValue = 20;
colValue = 30;
colValue = 40;
maxValue = 40;
} // default constructor
public static void setColValue(int colNum, int value)
colValue[colNum] = value;
maxValue = ( colValue[colNum] >maxValue ? value : maxValue) ;
} // end of setter
public static int getColValue(int colNum)
public static int getMaxValue()
} // end of class columnValues;
Here is the driver:
public class BarDriver
public static void main(String args)
ColumnValues cValues = new ColumnValues();
int width, height;
dummyValue = ColumnValues.getColValue(1);
JOptionPane.showMessageDialog(null, Integer.toString(dummyValue), "Hi",
: The second to the last line gives me null pointer error..
Can some one please help and tell me what I did wrong? Thank you very much..
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL