求助!Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
来源:百度知道 编辑:UC知道 时间:2024/07/04 07:30:33
我写了一个类,编译没错,执行就有上面的问题,也不能调用里面的addword函数!原代码如下:
类:
import java.awt.*;
public class Fun
{
public String dic[][];
public String temp[][];
public int count ;
public int size ;
public int MAX ;
public void init()
{
count = 0;
size = 5;
MAX = 5;
dic = new String[size][2];
}
public boolean addword(String english, String chinese)
{/**
* 编写添加单词功能
*@param english the englishword need added
*@param chinese the chineseword need added
*
*/
int n;
if (count == size)
{
temp = new String[MAX+size][2];
for (n = 0; n < count; n++)
{
temp[n][0] = dic[n][0];
temp[n][1] = dic[n][1];
}
dic = new String[MAX+size][2];
size = size + MAX;
dic = temp;
}
dic[count][0] = english;
dic[count][1] = chinese;
类:
import java.awt.*;
public class Fun
{
public String dic[][];
public String temp[][];
public int count ;
public int size ;
public int MAX ;
public void init()
{
count = 0;
size = 5;
MAX = 5;
dic = new String[size][2];
}
public boolean addword(String english, String chinese)
{/**
* 编写添加单词功能
*@param english the englishword need added
*@param chinese the chineseword need added
*
*/
int n;
if (count == size)
{
temp = new String[MAX+size][2];
for (n = 0; n < count; n++)
{
temp[n][0] = dic[n][0];
temp[n][1] = dic[n][1];
}
dic = new String[MAX+size][2];
size = size + MAX;
dic = temp;
}
dic[count][0] = english;
dic[count][1] = chinese;
1.
//d1 = new Fun();
被你注释掉了吧!
2.
public void init()
{
count = 0;
size = 5;
MAX = 5;
dic = new String[size][2];
}
去掉void !构造函数不能为空!
3.其他你在找找 ,可能有变量为空
应该是第二点 把构造函数名改为public Fun 试试!
共同提高1
Exception EOleSysError in module
求助问题:Exception in thread "main" java.lang.NullPointerException
Exception in thread "main" java.lang.NoXuchMethodError: main
Exception in thread "main" java.lang.NoClassDefFoundError
java出现错误Exception in thread "main"...
Exception in thread "main" java.lang.NoClassDefFoundError: HelloDate
Exception in thread "main" java.lang.NoClassDefFoundError:文件名
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
Exception in thread "main" java.lang.NoClassDefFoundError:
Exception in thread "main" java.lang.NoclassDefFoundError:yihangjia