因为你没有初始化(就进行了申明),所以为空。
你是在getint()方法中对pp赋值,所以如果想不空,要不调用getint()方法,要不初始化

解决方案 »

  1.   

    public int getinfo()
    {
    getint();
     return this.pp;
    }
      

  2.   

    你没有复制当然是空了
    int pp = 2
    或者
    public int getinfo()
    {
    getint();
     return this.pp;
    }
      

  3.   

    不同意楼上几位,private int pp;
    默认值为0
      

  4.   

    public int getinfo()
    {
    getint();
     return this.pp;
    }如果是这样的话,我的程序就有错误了
    我想要
    public void getint()
    {
     pp=2;
    }
    中的pp值~~
      

  5.   

    同意楼上,如
    class Moto{ private static int i;
    public void setInit(){
    i = 10;
    } public static String getInt(){
    return "i = " + i;
    } public static void main(String[] args) {
    System.out.println(getInt());
    }
    }显示i = 0
      

  6.   

    没有办法获得
    public void setInit()
    {
      i = 10;
    }
    中的i值吗~~?
      

  7.   

    public int getinfo()
    {
    getint();
     return this.pp;
    }如果是这样的话,我的程序就有错误了
    我想要
    public void getint()
    {
     pp=2;
    }
    中的pp值~~————————————————————
    怎么有错呢?你把错误打出来看看
      

  8.   

    ApplicationDispatcher[]: Servlet.service() for servlet debugjsp threw exceptionjava.lang.NullPointerException
      

  9.   

    getint应该改为setint吧,你调用了这个函数吗??
    这是个简单问题,自己可以解决的