java运行出现“Exception in thread "main" java.lang.NullPointerException?
jdbc出现以下问题:这是代码:packagecom.jdbc.action;importjava.util.List;importcom.jdbc.dao.Goddes...
jdbc出现以下问题:
这是代码:
package com.jdbc.action;
import java.util.List;
import com.jdbc.dao.GoddessDao;
import com.jdbc.model.Goddess;
public class GoddesAction {
public static void main(String[] args) throws Exception {
GoddessDao g = new GoddessDao();
List<Goddess> gs = g.query();
for (Goddess goddess : gs){
System.out.println(goddess.getUser_name() + "," + goddess.getAge());
}
}
}
以下是运行结果:
kiki,22
Exception in thread "main" java.lang.NullPointerException
at com.jdbc.action.GoddesAction.main(GoddesAction.java:16) 展开
这是代码:
package com.jdbc.action;
import java.util.List;
import com.jdbc.dao.GoddessDao;
import com.jdbc.model.Goddess;
public class GoddesAction {
public static void main(String[] args) throws Exception {
GoddessDao g = new GoddessDao();
List<Goddess> gs = g.query();
for (Goddess goddess : gs){
System.out.println(goddess.getUser_name() + "," + goddess.getAge());
}
}
}
以下是运行结果:
kiki,22
Exception in thread "main" java.lang.NullPointerException
at com.jdbc.action.GoddesAction.main(GoddesAction.java:16) 展开
2个回答
2016-09-06
展开全部
空指针异常,对象goddess中user_name 或者 age 为null值
追问
如何破?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询