java,img.getWidth(null);为什么会报出空指针异常 5C

package Plane;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.event.KeyEvent;

import Util.GameUtil;

public class Plane {
double x,y;
Image img;
boolean left,right,up,down;
double speed = 10;
int width ;
int height ;

/**
 * Rectangle类,新建一个矩形
 * @return
 */
public Rectangle getRect() {
    Rectangle rect = new Rectangle((int)x,(int)y,width,height);
    return rect;
}
public void draw(Graphics g) {
    g.drawImage(img, (int)x, (int)y, null);
    move();
}

public Plane(String imgPath , double x, double y) {
    super();
    this.x = x;
    this.y = y;
    this.width = img.getWidth(null);
    this.height = img.getHeight(null);

    this.img = GameUtil.getImage(imgPath);

}
public void move () {
    if(left) {
        x -= speed;
    }
    if(right) {
        x += speed;
    }
    if(up) {
        y -= speed;
    }
    if(down) {
        y += speed;
    }
}
public void addDirection(KeyEvent e) {
    switch(e.getKeyCode()) {
    case KeyEvent.VK_LEFT:
        left = true;
        break;
    case KeyEvent.VK_RIGHT:
        right = true;
        break;
    case KeyEvent.VK_UP:
        up = true;
        break;
    case KeyEvent.VK_DOWN:
        down = true;
        break;
    default:
        break;

    }       
}
public void releaseDirection(KeyEvent e) {
    switch(e.getKeyCode()) {
    case KeyEvent.VK_LEFT:
        left = false;
        break;
    case KeyEvent.VK_RIGHT:
        right = false;
        break;
    case KeyEvent.VK_UP:
        up = false;
        break;
    case KeyEvent.VK_DOWN:
        down = false;
        break;
    default:
        break;

    }

}

}
package Plane;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;

import Util.GameUtil;
import Util.MyFrame;

public class PlaneFrame extends MyFrame{
Image bg = GameUtil.getImage("Image/bg.jpg");
Plane plane = new Plane("Image/plane.png", 300, 600);

ArrayList bulletList = new ArrayList(); 
public void paint(Graphics g) {
    g.drawImage(bg, 0, 0, null);
    plane.draw(g);
    for(int i=0;i<bulletList.size();i++) {
        Bullet b = (Bullet) bulletList.get(i); //get()返回此列表中指定位置的元素。 
        b.draw(g);

        //碰撞检测,每次画一个球就检测是否与飞机发生碰撞
        boolean impact = b.getRect().intersects(plane.getRect());//比较两个矩形是否相交
        if(impact) {
            System.out.println("sssssss");
        }
    }



}

 class KeyMonitor extends KeyAdapter {
        @Override
    public void keyPressed(KeyEvent e) {
        System.out.println("按下"+e.getKeyCode());

        plane.addDirection(e);

    }
    @Override
    public void keyReleased(KeyEvent e) {
        System.out.println("松开"+e.getKeyCode());
        plane.releaseDirection(e); //自己的理解,不写这个将方向改为false的方法的话,。。。。写了的话将就代表调用了move的方法
        //**不是很懂松开这个建不写方法就有问题

    }
};

public void LoadFrame() {
    super.LoadFrame();
    addKeyListener(new KeyMonitor());  
    /*addKeyListener
    public void addKeyListener(KeyListener l)

    for(int i=0;i<60;i++) {
        Bullet bll = new Bullet();
         bulletList.add(bll); 


    }

}
public static void main(String[] args) {
    new PlaneFrame().LoadFrame();
}

}

错误:file:/G:/develop/java1/SXTPlane/bin/Image/bg.jpg
Exception in thread "main" java.lang.NullPointerException
at Plane.Plane.(Plane.java:35)
at Plane.PlaneFrame.(PlaneFrame.java:14)
at Plane.PlaneFrame.main(PlaneFrame.java:71)

为什么img.getWidth(null);会报出空指针异常,图片是正常加载的,那为什么用对象来获取图片的长和高就报出空指针呢,萌新,不是很懂

3个回答

额,没有看具体代码,看题目有点问题,getWidth(null),给你报个空指针正常吧,你可以试试不加参数。

你贴的代码还不够用,只能从这几个方面猜一把:
1. img 变量是null(
看看是不是赋值过, if(img==null) System.out.println("图片未加载成功")

2. 图片没加载完毕(线程暂停1秒)

另外:
正在自学吧,刚开始入门吧?
java 怎么能从 awt 入手呢,java 不适合桌面编程,改 Java Web 吧。

qq_37260235
pursueone g.drawImage(img, (int)x, (int)y, null);而且我用的这句话画的这个类的图,能画出来应该代表img是不为空的吧
一年多之前 回复
qq_37260235
pursueone img应该不是空的,我试着打印了,没有出现为空,然后其他的就不怎么懂了,恩,学了点基础就想跟着视频做点东西,我知道不适合做桌面编程,就是想培养一下兴趣先,还没学到web,,嘿嘿
一年多之前 回复

你贴的代码还不够用,只能从这几个方面猜一把:
1. img 变量是null(
看看是不是赋值过, if(img==null) System.out.println("图片未加载成功")

2. 图片没加载完毕(线程暂停1秒)

另外:
正在自学吧,刚开始入门吧?
java 怎么能从 awt 入手呢,java 不适合桌面编程,改 Java Web 吧。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
为什么会报出NullPointerException
这个IO程序不知道为什么会报出NullPointerException,该怎么解决呢?rnpackage com.io2;rnrnimport java.io.File;rnimport java.util.ArrayList;rnrnpublic class ListAllTestrnrn //用于判断目录或文件所处的层次rn private static int time;rn rn // 递归的方法rn public static void deepList(File file) throws NullPointerExceptionrn rn if (file.isFile() || 0 == file.listFiles().length)rn rn return ;rn rn elsern rn File[] files = file.listFiles();rn rn files = sort(files);rn rn for(File f : files)rn rn StringBuffer output = new StringBuffer();rn rn if(f.isFile())rn rn output.append(getTabs(time));rn output.append(f.getName());rn rn elsern rn output.append(getTabs(time));rn output.append(f.getName());rn output.append("\\");rn rn rn System.out.println(output);rn rn if(f.isDirectory())rn rn time++;rn rn deepList(f);rn rn time--;rn rn rn rn rnrn // 整理文件数组,使得目录排在文件之前rn private static File[] sort(File[] files)rn rn ArrayList sorted = new ArrayList();rnrn // 寻找到所有的目录rn for (File f : files)rn rn if (f.isDirectory())rn rn sorted.add(f);rn rn rn // 寻找到所有的文件rn for (File f : files)rn rn if (f.isFile())rn rn sorted.add(f);rn rn rnrn return sorted.toArray(new File[files.length]);rn rn rn //判断需要加多少tab的方法rn private static String getTabs(int time)rn rn StringBuffer buffer = new StringBuffer();rn rn for(int i = 0; i < time; i++)rn rn buffer.append("\t");rn rn rn return buffer.toString();rn rn rn rn public static void main(String[] args) rn rn File file = new File("C:\\ProgramData");rn rn deepList(file);rn rn rn
为什么这个简单的小程序会报出空指针异常,很无语
为什么这个简单的小程序会报出空指针异常,很无语rnrn[code=Java]rnimport java.util.Date;rnimport java.util.Timer;rnrnimport com.gw.mail.MailTest;rnrnpublic class test rn rn public void start()rn Date datetime = new Date();rn Timer timer = null;rn System.out.println(datetime);rn timer.schedule(new MailTest(), datetime);rn rn rn rn public static void main(String[] args) rn test t = new test();rn t.start();rn rnrnrnrn[/code]rnrn报出的异常为:rn[code=Java]rnMon Apr 04 11:59:43 CST 2011rnException in thread "main" java.lang.NullPointerExceptionrn at test.start(test.java:12)rn at test.main(test.java:18)rn[/code]rnrnat test.start(test.java:12)这里指的是timer.schedule(new MailTest(), datetime);rnrnMailTest类得代码为:rn[code=Java]rnpackage com.gw.mail;rnrn//这是执行任务的类,即每隔一段时间要做的事情在这里 rnrnimport java.io.IOException;rnimport java.net.UnknownHostException;rnimport java.util.TimerTask;rnpublic class MailTest extends TimerTask rn @Override rn public void run() rn MailMessage message = new MailMessage();rn message.setFrom("xXX_j@163.com"); // 发送者rn message.setTo("xXX@qq.com"); // 收件者rn String server = "smtp.163.com"; // 发件者邮箱服务器rn message.setSubject("Java Mail Test"); // titlern message.setContent("Hello, this is GWVM system send mail test"); // contentrn message.setDataFrom("xX"); // 收到的邮件中发件人显示rn message.setDataTo("xX"); // 收到的邮件中收件人显示rn message.setUser("XXX_j@163.com"); // 发件箱的用户名rn message.setPassword("XXX"); // 发件箱的密码rnrn SMTPClient smtp;rn try rn smtp = new SMTPClient(server, 25);rn boolean flag;rn flag = smtp.sendMail(message, server);rn if (flag) rn System.out.println("邮件发送成功!");rn else rn System.out.println("邮件发送失败!");rn rn catch (UnknownHostException e) rn e.printStackTrace();rn catch (IOException e) rn e.printStackTrace();rn rn rnrn rn rn[/code]
安卓的intent报出空指针异常
当使用intent的时候报出NullPoiterException,具体是在调用这行代码的时候:rnrn int posizione2 =Integer.parseInt((getIntent().getExtras().getString(Intent.EXTRA_TEXT)));rnrn请多指教!谢谢rnrn private void aggiungiImm(View arg1, int arg2) rn Intent i=newintent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);rn i.putExtra(Intent.EXTRA_TEXT, Integer.toString(arg2));rn startActivityForResult(i, PICK_REQUEST); rn rn rn @Overridern protected void onActivityResult(int requestCode, int resultCode,Intent data) rn Uri contactData=null;rn if (requestCode==PICK_REQUEST) rn if (resultCode==RESULT_OK) rn contactData=data.getData(); rn int posizione2 =Integer.parseInt((getIntent().getExtras().getString(Intent.EXTRA_TEXT)));rnrn错误是不是和intent是隐式有关?rnrn
为什么会出现空指针异常
[code=Java]rnaddRoom.setOnClickListener(new android.view.View.OnClickListener()rn public void onClick(View v) rn builder = new AlertDialog.Builder(RoomSet.this);rn TableLayout addroom = (TableLayout)getLayoutInflater().inflate(R.layout.addroom, null);rn builder.setView(addroom);rn newRoomET = (EditText)findViewById(R.id.addroom_et);rn builder.setPositiveButton("确定"rn // 为按钮设置监听器rn , new android.content.DialogInterface.OnClickListener()rn rn public void onClick(DialogInterface dialog, int which)rn rn //此处可执行登录处理rn name = newRoomET.getText().toString();//[b]①处[/b]rn ...rn rn rn rnrn[/code]rnrn为什么①处会出现空指针异常。。。
为什么simpleDateFormat.format(null)会报空指针异常
SimpleDateFormat sdf = new SimpleDateFormat(&quot;yyyy-MM-dd HH:mm:ss&quot;); sdf.format(null);在第二行会报空指针异常,为什么呢?我们进入源码看一下就知道了。第一步public final String format(Date date) { return format(date, new Strin...
TabWidget 为什么会报出空指针
Activity 已经继承了TabActivity, 在调用tw.focusCurrentTab(index)获取焦点, tw 为TabWidget, 然后该句话抛出空指针,请问哪里错误? 困扰好几天了.
求为什么会出现空指针异常
import java.io.*;rnrnpublic class Dir rnrn /**rn * @param argsrn */rn public static void main(String[] args) rn // TODO Auto-generated method stubrn File f=new File("d:\\");rn File[] files = f.listFiles();rn System.out.println(files.length);rn //for(int i=0;i
""与null区别 空指针异常机理
String s1; String s2 = null; String s3 = ""; String s4 = "abc"; 二、空指针异常机理 1.什么叫空指针异常: 空指针的概念:也就是只有变量名(指针变量)这个容器,里面没有任何的内存地址,也就是里面是空的,就叫空指针。 注:a、在java里方法是需要对象去调用的,格式如:对象名.方法名;        b、java里的对
为什么会报出文件未找到异常?
我创建一个文件对象 用的当前路径下的 Test1.javarn当前路径下 有这个文件 可是程序一运行就报出未发现文件异常rn我在CMD下面编译运行都可以rn就是用Eclipse运行就提示异常 这是为什么?rnrn求教rn代码如下:rnrn[code=java] /*rn * 需求:7、 自定义字符输入流的包装类,通过这个包装类对底层字符输入流进行包装rn * 让程序通过这个包装类读取某个文本文件(例如,一个java源文件)时,能够在读取的每行前面都加上有行号和冒号。rn *rn * */rnrn package com.itheima;rnrn import java.io.BufferedReader;rn import java.io.File;rn import java.io.FileNotFoundException;rn import java.io.FileReader;rn import java.io.IOException;rnrn public class Test7 rn public static void main(String args[])rn rn File file = null;rn file = new File("Test1.java");rn ReaderPackaging rp = new ReaderPackaging(file);rn System.out.print(rp.readFile());rn rn rn rnrn rnrn class ReaderPackagingrn rn File file;rnrn //构造函数,传入被操作的文件rn ReaderPackaging(File file)rn rn this.file = file;rn rn rn //定义读取流对象rn BufferedReader readinfo = null;rn rn //定义行号计数器,默认为1开始rn private int linecount=1;rn rn rnrn public String readFile()rn rn try rn //为读取流对象关联rn readinfo = new BufferedReader(new FileReader(file));rn catch (FileNotFoundException e) rn e.printStackTrace();rn rn //定义一个字符串容器,用以存放添加行号和冒号后的字符串数据rn StringBuilder tempbuf = new StringBuilder("");rn rn //临时存储一行字符串rn String line = null;rn rn //调用BufferedReader的readLine方法一次读取一行,存入line(临时存储字符串)中rn //然后在加上行号和冒号后添加进入字符串容器中rn try rn while((line=readinfo.readLine())!=null)rn rn tempbuf.append(linecount+":"+line+"\r\n");rn linecount++;rn rn catch (IOException e) rn e.printStackTrace();rn rn //返回带行号和冒号的字符串容器的字符串表现形式rn return tempbuf.toString();rn rn rn rn rnrn [/code]
一个空指针异常null==1
Integer t =null ; if(t==100){ System.out.println(t); }     以上会报空指针  Exception in thread &quot;main&quot; java.lang.NullPointerException at test.test1.main(test1.java:35)  
1、 dao报空指针异常 空指针异常 problemDAO=null
解决方法 没有加注入标志@Autowired,
java 自动拆箱导致的空指针异常 Integer null == 0
今天就碰到了这个很神奇的事情。 上代码 : if(CategoryList.get(j).getReportType() == 0) 这是一个判断类型是否等于0. 我在类里声明的变量是Integer类型的。Integer和基础类型比较时候会自动拆箱, null转为基础类型会报空指针异常。被坑了,留篇文章记录一下。以后不再踩它...
为什么CreateInstance会返回NULL?
文件A:rnrnusing System;rnrnusing System.Collections.Generic;rnusing System.Text;rnusing System.Runtime.InteropServices;rnrnrnusing System.Threading;rnrnusing System.Windows.Forms;rnrnrnrnnamespace BackServicernrnrn rnrn rn public class Programrn rn rn rn rn rnrn rn public class MathClass//要定义为publicrn rnrn //私有变量rn public static int m_testi;rnrn private int x;rnrn private int y;rnrn //无参数的构造函数rnrn public MathClass()rn rnrn this.x = 0;rnrn this.y = 0;rnrnrn m_testi = 0;rnrn rnrn rnrn rn public int Add()rn rnrnrnrn return m_testi;rnrn rnrnrnrnrnrn rnrn rnrnrnrnrn rnrnrnrnrn文件B:rnrnusing System;rnrnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Text;rnusing System.Windows.Forms;rnusing abcTest.view;rnrnusing System.Reflection;rnusing BackService;rnusing System.Windows.Forms;rnrnnamespace abcTestrnrn public partial class LoginView : Formrn rn public LoginView()rn rn InitializeComponent();rn this.ControlBox = false;rn rnrn rnrn private void button1_Click(object sender, EventArgs e)rn rn rn rn Assembly asm = Assembly.Load("BackService");rn rn rnrn object obj = asm.CreateInstance("BackService.MathClass");rnrn rnrn if (null == obj)rn rnrn MessageBox.Show("动态创建对象失败!");rnrn rn elsern rn MessageBox.Show("创建好了!");rn rnrnrn Type t = typeof(MathClass);rnrn MessageBox.Show("开始调用方法!");rnrn int result = (int)t.InvokeMember("Add", BindingFlags.InvokeMethod, null, obj, null);rnrn string aa;rnrn //aa.ToString(result);rn string strresult = result.ToString();rnrn MessageBox.Show(strresult);rn rn rn rn rn rnrn private void button2_Click(object sender, EventArgs e)rn rn Application.Exit();rn rnrnrn rnrn //end classrn rn rnrnrnrn这个为什么会出异常呢?rnobject obj = asm.CreateInstance("BackService.MathClass");rnrn如果改成 object obj = asm.CreateInstance("MathClass");rn则返回的obj为NULL。rnrn应该如何修改呢?rnrn
为什么会出现null值?
现在有两个表 rn表1是商品种类 里面有一个字段名 kucun (库存)rn表2是每条订单记录 里面有一个字段名 jianshu(件数)rn当表2有新纪录时,就会统计jianshu(件数)然后更新 表1的库存rnrnCREATE TRIGGER trig_2rnon 表2rnFOR INSERTrnAS rn UPDATE rn arn SET rn kucun = kucun - jianshurn FROM rn 表1 a,inserted b rn WHERE rn a.id = b.sridrnGOrnrn可是在调试的时候rn得到的kucun却是nullrn请问各位达人 这是怎么回事?
request.getQueryString()为什么会返回NULL???
如题
sendMessage 这里为什么会抛空指针异常呢
PendingIntent pi =PendingIntent.getActivity(EditMessage.this, 0, new Intent(), 0);n//抛出空指针异常nsmsManager.sendTextMessage(number,null,editText.getText().toString(),pi,null);nnn实在是不明白,number是好的,editText得出来的文本也是好的,为什么会有空指针呢?nn小白实在是不懂了,真的调不动了,需要帮助。。。。
求问 java为什么空指针异常
type Exception reportnnmessagenndescription The server encountered an internal error () that prevented it from fulfilling this request.nnexceptionnnorg.apache.jasper.JasperException: Exception in JSP: /select.jsp:36nn33: 鐢佃瘽n34: n35: <%n36: for(int i = 0;i < rsList.size();i++)n37: Map rsMap = rsList.get(i);n38: System.out.println("椹笂瑕佸惊鐜簡");n39: %> nnnStacktrace:n org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:467)n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:389)n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)n javax.servlet.http.HttpServlet.service(HttpServlet.java:803)nnroot causennjava.lang.NullPointerExceptionn org.apache.jsp.select_jsp._jspService(select_jsp.java:82)n org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)n javax.servlet.http.HttpServlet.service(HttpServlet.java:803)n org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)n org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)n org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)n javax.servlet.http.HttpServlet.service(HttpServlet.java:803)nnn
为什么会出现TreeSet.add 报空指针异常
rn在向TreeSet中add对象的时候,总是报空指针异常rn[code=java]rnimport java.util.Comparator;rnimport java.util.Iterator;rnimport java.util.Set;rnimport java.util.SortedSet;rnimport java.util.TreeSet;rnrnimport org.junit.Test;rnrn/*rn * 练习 TreeSet的自然排序和定制排序rn */rnpublic class TestTreeSet rn @Testrn public void test() rn //自然排序rn Set set = new TreeSet();rn set.add(new Item("Billy",4547));//此处报空指针异常rn set.add(new Item("Eric",3369));rn set.add(new Item("Magic",3608));rn for(Object obj:set)rn System.out.println(obj);rn rn rn //定制排序rn Comparator com = new Comparator() rn @Overridern public int compare(Item o1, Item o2) rnrn Item it1 = (Item) o1;rn Item it2 = (Item) o2;rn int i = it1.getPartNum().compareTo(it2.getPartNum());rn if (i == 0) rn return it1.getDescription().compareTo(it2.getDescription());rn else rn return i;rn rn rnrn ;rnrn SortedSet parts = new TreeSet(com);rn parts.add(new Item("Tom", 1456));rn parts.add(new Item("Sam", 2580));rn parts.add(new Item("Kimi", 3369));rn parts.add(new Item("Penny", 1234));rnrn for (Object obj : parts) rn System.out.println(obj);rn rn rnrn[/code]rnItem类,实现Comparable接口,实现hashCode,equals,compareTo方法rn[code=java]rnpublic class Item implements Comparable rnrn private String description;rn private Integer partNum;rn //构造器rn public Item()rn rn rn public Item(String description, Integer patrNum) rn super();rn this.description = description;rn this.partNum = partNum;rn rnrn public void setDescription(String description) rn this.description = description;rn rnrn public String getDescription() rn return this.description;rn rnrn public Integer getPartNum() rn return partNum;rn rn public void setPartNum(Integer partNum) rn this.partNum = partNum;rn rnrn @Overridern public String toString() rn return "Item [description=" + description + ", partNum=" + partNumrn + "]";rn rn rn @Overridern public int hashCode() rn final int prime = 31;rn int result = 1;rn result = prime * resultrn + ((description == null) ? 0 : description.hashCode());rn result = prime * result + ((partNum == null) ? 0 : partNum.hashCode());rn return result;rn rnrn @Overridern public boolean equals(Object obj) rn if (this == obj)rn return true;rn if (obj == null)rn return false;rn if (getClass() != obj.getClass())rn return false;rn Item other = (Item) obj;rn if (description == null) rn if (other.description != null)rn return false;rn else if (!description.equals(other.description))rn return false;rn if (partNum == null) rn if (other.partNum != null)rn return false;rn else if (!partNum.equals(other.partNum))rn return false;rn return true;rn rnrn @Overridern public int compareTo(Object o) rn if(o instanceof Item)rn Item it = (Item)o;rn int i = this.partNum.compareTo(it.partNum);rn if(i == 0)rn return this.description.compareTo(it.description);rn elsern return i;rn rn rn return 0;rn rnrn[/code]rnrn一直想不明白,初学java,请帮我看一下好吗
帮忙看下为什么会产生空指针异常呢
[code=Java]rnpackage test;rnrnimport java.util.Map;rnrnpublic class TestMap rn rn Map matchMap=null;rn rn public void addToMap(String hash,String tag)rn matchMap.put(hash, tag);rn rnrn public static void main(String argv[])rn TestMap t=new TestMap();rn t.addToMap("haha", "tag");rn rnrn[/code]rnrn代码如上,异常为:rnrnException in thread "main" java.lang.NullPointerExceptionrn at test.TestMap.addToMap(TestMap.java:10)rn at test.TestMap.main(TestMap.java:15)rnrn为啥呢?
Java加载静态图片时为什么会出现空指针异常
rn[img=https://img-bbs.csdn.net/upload/201706/11/1497161349_481197.png][/img]rnrn第15行报空指针异常rn
HashSet添加null报空指针异常
HashSet添加null报空指针异常。 public class TestSet { public static void main(String[] args) { Set&amp;lt;Integer&amp;gt; hashSet = new HashSet&amp;lt;Integer&amp;gt;(); hashSet.add(2); hashSet.ad...
java空指针异常问题 为何会出现空指针异常
npublic class Student n private int on;n private String name;n private int age;n private int java;n private int c;n private int html;n private int sql;n private int sum;n private int avg;n public int getOn() n return on;n n public void setOn(int on) n this.on = on;n n public String getName() n return name;n n public void setName(String name) n this.name = name;n n public int getAge() n return age;n n public void setAge(int age) n this.age = age;n n public int getJava() n return java;n n public void setJava(int java) n this.java = java;n n public int getC() n return c;n n public void setC(int c) n this.c = c;n n public int getHtml() n return html;n n public void setHtml(int html) n this.html = html;n n public int getSql() n return sql;n n public void setSql(int sql) n this.sql = sql;n n public int getSum() n return sum;n n public void setSum() n this.sum = this.java+this.c+this.sql+this.html;n n public int getAvg() n return avg;n n public void setAvg() n this.avg = this.sum/4;n n public String toString()n String msg="\t"+this.on+"\t"+this.name+"\t"+this.age+"\t"+this.javan +"\t"+this.c+"\t"+this.html+"\t"+this.sql+"\t"+this.sum+"\t"n +this.age;n return msg;n nnnnnnnnpublic class Admin //管理学生类n public void addStudent(String name,int age,Student[] stuArr)n Student stu=new Student();n int i=this.getIndex(stuArr);n stuArr[i]=stu;n stu.setName(name);n stu.setAge(age);n this.show(stuArr);n n public int getIndex(Student[] stuArr)n for(int i=0;i
java 空指针异常
java 空指针异常 老遇到这个报错。。   String param =  。。。。或者可以是 null; if ( param.equals( &quot;abcd&quot; ) ) {   // param 是 null 就会报错。所以需要先对字符串判空   。。。 } 另外,在 javabean 里定义 int 类型的属性也要小心。如果数据库里字段默认值是 null,读取出来后,直接给 int...
java空指针异常
(position不等于0)rnString temp[] = new String[15];rnif (position!=0)rnfor (int i=0; i < 15; i++) rn temp[i] = ss[i] + ": "+ ss[(position) * 15 + i].replaceAll(" ", "");rn rnrn这怎么就产生空指针异常了呢?求救啊 各位大神……
Java空指针异常
Java空指针异常出现的可能有多种,我前前后后就遇到了好多种。空指针,即指向了声明类型的类的空对象。 空指针异常出现的原因是什么,是将null值分配给一个未知对象的引用,当应用程序访问或者引用一个null值得时候,空指针异常就会被抛出。这个时候就需要好好检查一下代码,看值不能正确传入的原因是什么。总之,要细心啦,这个就是随便记录下,写的有点乱,不喜勿喷。
为什么(又见空指针异常null pointer exception 给100分)
时隔一年后,本人我又拿起了java,又遇见了让我头大的NullPointerException 空指针异常,大家帮我看看,代码如下:rnrnrnpublic class AdminLoginAction extends Action rn public ActionForward execute(ActionMapping mapping, rn ActionForm form,rn HttpServletRequest request,rn HttpServletResponse response) throws SQLException rn try rn request.setCharacterEncoding("gbk");rn catch (UnsupportedEncodingException e) rn e.printStackTrace();rn rn String userName = request.getParameter("userName");rn String password = request.getParameter("pwd");rn //String sql = new String("select * from operator where user_name='userName' and password='pwd' and group_id='1'");rn System.out.println("######" + userName + "*****");rn System.out.println(password);rn rn int group_id = 0;rn //Connection con;rn //Statement stmt;rn //con = DBConnection.getConnection();rn //stmt = con.createStatement();rn //stmt.executeQuery(sql);rn //ResultSet result = stmt.executeQuery(sql);rn //int i = 0;rn //while (result.next()) rn //i++;rn //rn //request.setAttribute("result", result);rn ArrayList result = (ArrayList)AdminUser.find(userName,password,group_id);//tomcat提示有错 ,第 50 行rn if(result.size()<0)rn result = new ArrayList();rn System.out.println(result.size());rn if(result.size()>0) rn request.setAttribute("result",result);rn return mapping.findForward("success");rn elsern return mapping.findForward("failure");rn rn rnrn第 50 行提示有错
num_before(before) = Null为什么会出错
num_before(1 to 100)声明为string型了rnbefore 为long型rn难道不能定义为null?rn
为什么在Flume中加入自定义interceptor会报出ClassNotFoundException
RT,我想在Flume中加入一个自定义的拦截器,可是遇到了问题rn下面是我flume的配置文件:rnagent.sources=s1rnagent.channels=c1rnagent.sinks=k1rnrnagent.sources.s1.type=syslogtcprnagent.sources.s1.host=192.168.1.37rnagent.sources.s1.port=i20000rnagent.sources.s1.channels=c1rnagent.sources.s1.interceptors =i1rnagent.sources.s1.interceptors.i1.type=com.flume.interceptor.HbInterceptor$Builderrnrnagent.sinks.k1.type=file_rollrnagent.sinks.k1.sink.directory=/soft/flume/file_sinkrnagent.sinks.k1.sink.serializer=textrnagent.sinks.k1.channel=c1rnrnagent.channels.c1.type=memoryrnagent.channels.c1.capacity=1000rnagent.channels.c1.transactionCapacity=500rn下面代码是我自定义的拦截器类:rnpackage com.flume.interceptor;rnrnimport java.util.ArrayList;rnimport java.util.Arrays;rnimport java.util.List;rnrnimport org.apache.flume.Context;rnimport org.apache.flume.Event;rnimport org.apache.flume.interceptor.Interceptor;rnrnpublic class HbInterceptor implements Interceptor rn rn HbInterceptor()rn rn rnrn public void close() rnrn rnrn public void initialize() rnrn rnrn public Event intercept(Event event) rn try rn byte[] body = event.getBody();rn byte[] frame = Arrays.copyOfRange(body, 0, 2);rn if (frame[0] == '#' && frame[1] == '#') rn byte[] dataLen = Arrays. copyOfRange(body, frame.length,rn frame.length + 4);rn String dataLenStr = String.valueOf(dataLen);rn int dataLength = Integer.parseInt(dataLenStr);rn byte[] data = Arrays.copyOfRange(body, frame.lengthrn + dataLen.length, frame.length + dataLen.lengthrn + dataLength);rn byte[] crcCheck = Arrays.copyOfRange(body, frame.lengthrn + dataLen.length + dataLength, frame.lengthrn + dataLen.length + dataLength + 4);rn int dataCRC = ByteStrToInt(crcCheck);rn int CrcSum = checkOutSixteenCheckSum(data, dataLength);rn if (dataCRC == CrcSum) rn event.setBody(data);rn else rn event = null;rn rn else rn event = null;rn rn catch (Exception e) rn e.printStackTrace();rn rnrn return event;rn rnrn public List intercept(List events) rn List intercepted = new ArrayList();rn for (Event event : events) rn Event interceptorEvent = intercept(event);rn if (interceptorEvent != null) rn intercepted.add(interceptorEvent);rn rn rn return intercepted;rn rn rn public static class Builer implements Interceptor.Builderrnrn public void configure(Context context) rn rn rnrn public Interceptor build() rn return new HbInterceptor();rn rnrn rnrn // \u5c06\u7ec8\u7aef\u8ba1\u7b97\u7684CRC\u8ba1\u7b97\u503c\u8f6c\u5316\u6210int\u578brn public int ByteStrToInt(byte[] checkSum) rn String str = new String(checkSum);rn int iValule = Integer.parseInt(str, 16);rn return iValule;rn rnrn // 212\u534f\u8bae\u7684CRC\u6821\u9a8c\u7b97\u6cd5rn private int checkOutSixteenCheckSum(byte[] bytes, int len) rn int r = 0xffff;rn char hi;rn char flag;rn for (int i = 0; i < len; i++) rn hi = (char) (r >> 8);rn hi ^= bytes[i];rn r = hi;rnrn for (int j = 0; j < 8; j++) rn flag = (char) (r & 0x0001);rn r = r >> 1;rn if (flag == 1) rn r ^= 0xa001;rn rn rn rn return r;rn rnrn我将上面的工程打成jar包放到了flume根目录中lib文件夹中,然后用上面的配置文件运行会报出java.lang.ClassNotFoundException: com.flume.interceptor.HbInterceptor$Builderrn at java.net.URLClassLoader$1.run(URLClassLoader.java:366)rn at java.net.URLClassLoader$1.run(URLClassLoader.java:355)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:354)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:425)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:358)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:190)rn at org.apache.flume.interceptor.InterceptorBuilderFactory.newInstance(InterceptorBuilderFactory.java:48)rn at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:111)rn at org.apache.flume.channel.ChannelProcessor.configure(ChannelProcessor.java:82)rn at org.apache.flume.conf.Configurables.configure(Configurables.java:41)rn at org.apache.flume.node.AbstractConfigurationProvider.loadSources(AbstractConfigurationProvider.java:348)rn at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:101)rn at org.apache.flume.node.PollingPropertiesFileConfigurationProvider$FileWatcherRunnable.run(PollingPropertiesFileConfigurationProvider.java:141)rn at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)rn at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)rn at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)rn at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)rn at java.lang.Thread.run(Thread.java:745)rn2017-03-13 11:26:20,128 (conf-file-poller-0) [ERROR - org.apache.flume.node.AbstractConfigurationProvider.loadSources(AbstractConfigurationProvider.java:361)] Source s1 has been removed due to an error during configurationrnorg.apache.flume.FlumeException: Interceptor.Builder not found.rn at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:116)rn at org.apache.flume.channel.ChannelProcessor.configure(ChannelProcessor.java:82)rn at org.apache.flume.conf.Configurables.configure(Configurables.java:41)rn at org.apache.flume.node.AbstractConfigurationProvider.loadSources(AbstractConfigurationProvider.java:348)rn at org.apache.flume.node.AbstractConfigurationProvider.getConfiguration(AbstractConfigurationProvider.java:101)rn at org.apache.flume.node.PollingPropertiesFileConfigurationProvider$FileWatcherRunnable.run(PollingPropertiesFileConfigurationProvider.java:141)rn at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)rn at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)rn at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)rn at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)rn at java.lang.Thread.run(Thread.java:745)rnCaused by: java.lang.ClassNotFoundException: com.flume.interceptor.HbInterceptor$Builderrn at java.net.URLClassLoader$1.run(URLClassLoader.java:366)rn at java.net.URLClassLoader$1.run(URLClassLoader.java:355)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(URLClassLoader.java:354)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:425)rn at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)rn at java.lang.ClassLoader.loadClass(ClassLoader.java:358)rn at java.lang.Class.forName0(Native Method)rn at java.lang.Class.forName(Class.java:190)rn at org.apache.flume.interceptor.InterceptorBuilderFactory.newInstance(InterceptorBuilderFactory.java:48)rn at org.apache.flume.channel.ChannelProcessor.configureInterceptors(ChannelProcessor.java:111)rn ... 12 morern刚开始就接触Flume,求大神给指出哪里出问题了,谢谢!
两个指向null的字符串为什么会相等?
如果 rnString a=null; rnString b=null; rnrna==b? rnrn运行结果truern为什么啊 ?rn没分了不能提供分数了rn晕rn
为什么request.getparamer()会显示null的??代码以下:
[code=text]rn<%@ page contentType="text/html" pageEncoding="GBK"%>rnrn loginrnrn rn用户名: rn密 码: rn rnrn<%=request.getParameter("uname")%>rnrnrn[/code]rn
这段代码为什么会返回null
[code=HTML]rnrnrn rn 无标题文档rn rnrnrnrn rn rnrnrn[/code]
为什么会出现 Null pointer assignment??
在做功课的时候发现了个问题,当程序运行完毕时总是出现Null pointer assignment语句rn怎么改都改不过来~!请帮我看看,谢谢呀~!rn代码:rn#includern#includern#includernrnchar *S1;rnrnvoid cmp(char s[]);rnvoid gett();rnvoid getd();rnrnvoid main()rnrn for(;;)rn rn printf("@:>");rn scanf("%s",S1);rn cmp(S1);rn rnrnrnvoid cmp(char s[])rnrn if(strcmp(s,"end")==0) exit(1);rn if(strcmp(s,"time")==0) gett();return;rn if(strcmp(s,"date")==0) getd();return;rn printf("Bad command!\n\n");rnrnrnvoid gett()rnrn struct time T;rn gettime(&T);rn printf("TIME:%d:%d:%d.%d\n\n",T.ti_hour,T.ti_min,T.ti_sec,T.ti_hund);rnrnrnvoid getd()rnrn struct date D;rn getdate(&D);rn printf("DATE:%d-%d-%d\n\n",D.da_year,D.da_mon,D.da_day);rnrnZ
为什么HDC hdc=GetDC(NULL)会出错
rn'GetDC' : function does not take 1 parameters
为什么输出会显示NULL pointer assignment?
这是一个双向链表rn/* DNodeStr.txt */rnrn#include rn#define ElemType charrnrnstruct DNodernrn ElemType data;rn struct DNode *right, *left;rn;rnrn/* DNodeMut.txt */ rn#include "DNodeStr.txt"rnrnsetnull (struct DNode **p)rnrn *p=NULL;rnrnrnint length (struct DNode **p)rnrn int n=0;rn struct DNode *q;rn q=*p;rn while (q!=NULL)rn rn n++;rn q=q->right;rn rn return (n);rnrnrnElemType get (struct DNode **p, int i)rnrn int j;rn struct DNode *q;rn q=*p;rn for (j=1; jright;rn if (q!=NULL)rn return (q->data);rn elsern printf ("wrong location number!\n");rnrnrnrnint locate (struct DNode **p, ElemType x)rnrn int j=1;rn struct DNode *q;rn q=*p;rn while (q!=NULL && q->data!=x)rn rn q=q->right;rn j++;rn rn if (q!=NULL)rn return (j);rn elsern return (-1);rnrnrnvoid insert (struct DNode **p, ElemType x, int i)rnrn int j;rn struct DNode *s,*q;rn q=*p;rnrn s=(struct DNode *) malloc (sizeof (struct DNode));rn s->data=x;rn s->left=NULL;rn s->right=NULL;rnrn if (i==1)rnrn rn s->right=q;rn q->left=s;rn *p=s;rn rn elsern rn for (j=1; jright!=NULL; j++)rn q=q->right;rn if (j==i-1)rn rn if (q->right!=NULL)rn rn s->right=q->right;rn q->right->left=s;rn q->right=s;rn s->left=q;rn rn elsern rn q->right=s;rn s->left=q;rn rn rn elsern printf("wrong location number!\n");rnrnrnvoid del (struct DNode **p, int i) rnrn struct DNode *q,*t;rn q=*p;rn t=q;rn if (i==1)rn rn q=q->right;rn if (q!=NULL)rn rn q->left=NULL;rn *p=q;rn rn rn elsern rn for (int j=1; jright!=NULL; j++)rn q=q->right;rn if (j=i-1)rn rn if (q->right->right!=NULL)rn rn t=q;rn q->right=t->right->right;rn q->right->left=t;rn rn elsern q->right=NULL;rn rn elsern printf("wrong location number!\n");rn rnrn rnvoid display(struct DNode **p)rnrn struct DNode *q;rn q=*p;rn printf ("display the Double Node table: \n");rn if (q==NULL)rn printf ("Empty Double Node table.\n");rn else if (q->right==NULL)rn printf ("%c\n ", q->data);rn elsern rn while (q->right!=NULL)rn rn printf ("%c->", q->data);rn q=q->right;rn rn printf ("%c \n", q->data) rn rnrn rnrnrnrn/* DNodeMai.txt */rn#include "DNodeMut.txt"rnrnint main()rnrn struct DNode *head;rn setnull (&head);rn insert (&head, 'a', 1);rn insert (&head, 'b', 2);rn insert (&head, 'c', 2);rn insert (&head, 'd', 1);rn display (&head); /*the output should be: dacb */rn printf("The length of the LNode is: %d \n", length (&head));rn printf("The location of the elem a is: %d \n", locate(&head, 'a'));rn printf("The value of the location 3 is: %c \n", get (&head, 3));rn del (&head, 2);rn display (&head); /*the output should be: dcb */rn printf("The length of the LNode is: %d \n", length (&head));rnrn
inputStream.close()为什么造成空指针异常
package com.example.http;rnrnimport java.io.BufferedReader;rnimport java.io.IOException;rnimport java.io.InputStream;rnimport java.io.InputStreamReader;rnrnimport org.apache.http.HttpEntity;rnimport org.apache.http.HttpResponse;rnimport org.apache.http.client.HttpClient;rnimport org.apache.http.client.methods.HttpGet;rnimport org.apache.http.impl.client.DefaultHttpClient;rnimport android.support.v7.app.ActionBarActivity;rnimport android.os.Bundle;rnimport android.view.View;rnimport android.webkit.WebView;rnimport android.widget.Button;rnimport android.view.View.OnClickListener;rnrnpublic class MainActivity extends ActionBarActivity rnrn private Button mSendReqBtn = null;// 发送请求的按钮rn private WebView mWebView = null;// 用于显示结果,用载入html字符串的方式显示响应结果,而不是使用WebView自己的方式加载URLrnrn // 响应rn private HttpResponse mHttpResponse = null;rn // 实体rn private HttpEntity mHttpEntity = null;rnrn @Overridern protected void onCreate(Bundle savedInstanceState) rn super.onCreate(savedInstanceState);rn setContentView(R.layout.activity_main);rn mSendReqBtn = (Button) findViewById(R.id.requestBtn);rn mSendReqBtn.setOnClickListener(mSendClickListener);rnrn mWebView = (WebView) findViewById(R.id.webview);rn rnrn private OnClickListener mSendClickListener = new OnClickListener() rnrn @Overridern public void onClick(View v) rn // 生成一个请求对象rn HttpGet httpGet = new HttpGet("https://www.baidu.com/");rn // 生成一个Http客户端对象rn HttpClient httpClient = new DefaultHttpClient();rnrn InputStream inputStream = null;rn try rn // 发送请求并获得响应对象rn mHttpResponse = httpClient.execute(httpGet);rnrn mHttpEntity = mHttpResponse.getEntity();rnrn // 获取一个输入流rn inputStream = mHttpEntity.getContent();rnrn BufferedReader bufferedReader = new BufferedReader(rn new InputStreamReader(inputStream));rnrn String result = "";rn String line = "";rnrn while (null != (line = bufferedReader.readLine())) rn result += line;rn rnrn // 将结果打印出来,可以在LogCat查看rn System.out.println(result);rnrn // 将内容载入WebView显示rn mWebView.getSettings().setDefaultTextEncodingName("UTF-8");rn // 直接使用mWebView.loadData(result, "text/html", "utf-8");会显示找不到网页rnrn // 换成下面的方式可以正常显示(但是比较宽,拖动可见百度logo)rn mWebView.loadDataWithBaseURL(null, result, "text/html",rn "utf-8", null);rnrn // 直接载入URL也可以显示页面(但是此例子主要是为了验证响应返回的字符串是否正确,所以不用下面这行代码)rn // mWebView.loadUrl("http://www.baidu.com/");rn catch (Exception e) rn e.printStackTrace();rn finally rn try rn [color=#FF0000] inputStream.close();[/color]rn catch (IOException e) rn e.printStackTrace();rn rn rnrn rn ;rnrnrn
为什么总是出现“空指针异常”????!!!!
Hibernate+Tomcat+MySQL开发,信息说我这段代码有问题,突然间的rnrnpublic class UserBiz implements Serializablernrn // 登陆功能,用于判断登陆是否成功rn public User login( String userName , String password )rn rn User user = null ;rn Session session = null ;rn Transaction tx = null ;rn tryrn rn session = HbnUtil.getSession() ;rn tx = session.beginTransaction() ;rn Query query = session.createQuery( "from User as u where u.userName=:userName and u.password=:password" ).setString( "userName" , userName )rn .setString( "password" , password ) ;rn List list = query.list() ;rn if ( list.size() != 0 )rn rn Iterator iterator = list.iterator() ;rn while ( iterator.hasNext() )rn rn user = ( User ) iterator.next() ;rn rn rn tx.commit() ;rn catch ( HibernateException e )rn rn tx.rollback() ;rn e.printStackTrace();rn rn finallyrn rn // 访问数据库结束后必须关闭这个Session,以释放资源,这是必须的!!!!rn session.close() ;(说这一行有错误,空指针异常)rn rn return user ;rn rn
为什么 提示空指针异常啊....
包里面有两个文件,一个是midlet 另一个是class文件,我在class文件里面实现了 gamecanvas类,画了个地图和人物.然后在midlet文件里面实例化class文件类,为什么老是实例化失败,提示"java.lang.NullPointerException";
请教,为什么IIS会报出“服务器太忙”的错误?
急急
为什么抛出了空指针异常
我是想写一个登录界面,如现有两个界面:UserLogin和MainPagern 我要在UserLogin里单击一个按钮进入MainPage界面我的代码如下:rn mainFrame.setVisible(true);//mainFrame是MainPage的引用rn si.closeConnection();//关闭连接rn this.dispose();//消除对像rnrnrn在mainFrame.setVisible(true)这一行抛了异常:rn Exception in thread "AWT-EventQueue-0" java.lang.NullPointerExceptionrn at liu.model.UserLogin.actionPerformed(UserLogin.java:112)rn at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19rn95)rn at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.javrna:2318)rn at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModelrn.java:387)rn at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242rn)rn at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonLrnistener.java:236)rn at java.awt.Component.processMouseEvent(Component.java:6038)rn at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)rn at java.awt.Component.processEvent(Component.java:5803)rn at java.awt.Container.processEvent(Container.java:2058)rn at java.awt.Component.dispatchEventImpl(Component.java:4410)rn at java.awt.Container.dispatchEventImpl(Container.java:2116)rn at java.awt.Component.dispatchEvent(Component.java:4240)rn at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322rn)rn at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)rnrn at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)rn at java.awt.Container.dispatchEventImpl(Container.java:2102)rn at java.awt.Window.dispatchEventImpl(Window.java:2429)rn at java.awt.Component.dispatchEvent(Component.java:4240)rn at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)rn at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThrernad.java:273)rn at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.rnjava:183)rn at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThrernad.java:173)rn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)rnrn at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)rnrn at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)rn如果那位还其他的方法,将更加感谢.rn 排除错误真是累啊!一个通宵没睡都没解决.rn
时间格式化 为什么空指针异常?
private String jcongtime;rn//set getrnrnSimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");rnrnjcongtime=sdf.format(pi.getJiagongtime());rnrnpi是一个对象。jiagongtime是其字段 是Java.util.Date类型rnrn我在jsp页面 是要回显日期的:rn之前是这样写的:(没有用自己定义的jcongtime这个字段)rn
相关热词 c# stream 复制 android c# c#监测窗口句柄 c# md5 引用 c# 判断tabtip 自己写个浏览器程序c# c# 字符串变成整数数组 c#语言编程写出一个方法 c# 转盘抽奖 c#选中treeview