您的位置:首页 > 编程语言 > Java开发

struts2标签取值方式

2015-10-21 14:51 561 查看
如下面代码

 

public class Test
{
public static int a = 2;

public static void main(String[] args)
{
Test t = new Test();

t = null;

System.out.println(t.a);
}
}

 

 

输出为:

 

2

 

 

下面的代码

public class Test
{
public static int a = 2;
public int b = 3;

public static void main(String[] args)
{
Test t = new Test();

t = null;

System.out.println(t.a);
System.out.println(t.b);
}
}

 

 

输出为:

2
Exception in thread "main" java.lang.NullPointerException

 

 

再看下面的代码:

 

public class Test
{
public int a = 3;
public static int b = 2;

public static void main(String[] args)
{
Test t = new Test();

t = null;

System.out.println(t.a);
System.out.println(t.b);
}
}

 

 

输出为:

 

Exception in thread "main" java.lang.NullPointerException

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: