package first;
//import java.util.*;
public class Gouzao {
public Gouzao(String s) {
System.out.println("This is a test"+s);
}
Random rand=new Random();
public static void main(String[] args) {
Gouzao a[]=null;
Gouzao b=new Gouzao("aa");
a[0]=b;
a[1]=b;
a[2]=b;
for (int i=0;i<a.length ;i++ ) {
System.out.println(a[i]);
}
}
}当我运行的是侯,结果显示为:
java.lang.NullPointerException
at first.Gouzao.main(Gouzao.java:20)
Exception in thread "main" This is a testaa
请高手帮我看看。不胜感激!
//import java.util.*;
public class Gouzao {
public Gouzao(String s) {
System.out.println("This is a test"+s);
}
Random rand=new Random();
public static void main(String[] args) {
Gouzao a[]=null;
Gouzao b=new Gouzao("aa");
a[0]=b;
a[1]=b;
a[2]=b;
for (int i=0;i<a.length ;i++ ) {
System.out.println(a[i]);
}
}
}当我运行的是侯,结果显示为:
java.lang.NullPointerException
at first.Gouzao.main(Gouzao.java:20)
Exception in thread "main" This is a testaa
请高手帮我看看。不胜感激!
Gouzao a[]=new Gouzao[3];
import javax.swing.table.*;public class InAndOutTableModel extends AbstractTableModel {
private Object[][] data=null;
private String[] columnNames=null;
public InAndOutTableModel() {
}
public int getRowCount() {
return data!=null?data.length:0;
}
public int getColumnCount() {
return columnNames!=null?columnNames.length:0;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return data!=null?data[rowIndex][columnIndex]:"";
}
public void setColumnNames(String[] columnNames){
this.columnNames=columnNames;
}
public void setData(String[][] data){
this.data=data;
}}
但打印的结果将是对象的地址。
private String[] columnNames=new String[3];下次发贴要出新主题哦