急急急!!!Java出现java.lang.nullpointerException错误

import ch2.data.*;
public class AppTest {
public static void main(String []args) {
new CreateDatabaseAndTable();
Word word = new Word();
String [][] a = { {“broad”,“宽阔的”,"[br??d]",“His shoulders were broad and his waist narrow.”},{“brief”,“简洁的”,"[bri:f]",“In brief,take no risks whatever.”},
{“outdoor”,“在户外”,"[?a?td??®]",“Children like to play outdoors.”},{“public”,“公共的”,"[?p?bl?k]",“You mustn’t do that in a public place.”},
{“steep”,“陡峭的”,"[sti:p]",“The slope is too steep for us to climb.”},{“accuse”,“指责”,"[??kju?z]",“She accused him of being late.”}
};
AddWord addWord = new AddWord();
for(int i=0;i<a.length;i++){
word.setEnglishWord(a[i][0]);
word.setMeaning(a[i][1]);
word.setPronunciation(a[i][2]);
word.setSentence(a[i][3]);
addWord.insertWord(word);
}
QueryOneWord q = new QueryOneWord();
word.setEnglishWord(“accuse”);
Word re =q.queryOneWord(word);
System.out.println(“查询到的一个单词:”);
System.out.printf("%-10s",re.getEnglishWord()); //出现错误
System.out.printf("%-10s",re.getMeaning());
System.out.printf("%-10s",re.getPronunciation());
System.out.printf("%-10s\n",re.getSentence());
QueryAllWord query = new QueryAllWord();
Word [] result =query.queryAllWord();
System.out.println(“全部单词:”);
input(result);
RandomQueryWord random = new RandomQueryWord();
random.setCount(3); //随机抽取3个单词
result = random.randomQueryWord();
System.out.println(“随机抽取”+random.getCount()+“个单词:”);
input(result);
UpdateWord update = new UpdateWord();
word.setEnglishWord(“outdoor”);
word.setMeaning(“户外的; 室外的; “);
update.updateWord(word);
UpdateSentence updatesentence = new UpdateSentence();
word.setEnglishWord(“outdoor”);
word.setSentence(“If you enjoy outdoor activities, this is the trip for you.”);
updatesentence.updateWord(word);
DelWord del = new DelWord();
word.setEnglishWord(“broad”);
del.delWord(word);
word.setEnglishWord(“brief”);
del.delWord(word);
System.out.println(“更新、删除后全部单词:”);
query = new QueryAllWord();
result =query.queryAllWord();
input(result);
}
static void input(Word [] result){
for(int i=0;i<result.length;i++){
System.out.printf(”%-10s”,result[i].getEnglishWord());
System.out.printf("%-10s",result[i].getMeaning());
System.out.printf("%-10s",result[i].getPronunciation());
System.out.printf("%-10s",result[i].getSentence());
System.out.println();
}
}
}

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:数字20 设计师:CSDN官方博客 返回首页

打赏作者

shmily_dx

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值