What is the name of this class?

I have a JTable which is instantiated like this:

"class table2extends JTable{

privateint rows = 100, cols = 8;

private Object[] rowData =new Object[cols];

...

"

When I try to refer to it as "table2," I get a null pointer exception.

My questions:

What is the name of that class?

Is there a way to reference it as "table2"?

Many thanks in advance.

[683 byte] By [javaqq] at [2007-9-26 1:26:21]
# 1

Hello

I might have the answer to your problem but firstly, is that all the code there is? For example, where is the constructor for your class?

In answer to your questions:

1. You cannot reference an object until it has been created (this might explain the NullPointerException)

2. To reference it as "table2" you would do something like this:

table2 table2 = new table2();

Looks a bit confusing... :(

You should start class names with capital letters and also choose a general name for the class like this:

MyTable table2 = new MyTable();

MyTable table3 = new MyTable();

and so on.

Post another message if you need more help.

Regards

Daniel Lam

Daniel_Lam at 2007-6-29 1:09:08 > top of Java-index,Archived Forums,Swing...