由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 怎么返回空指针呢?
相关主题
库里有一个函数名也叫TimeRe: Question: Java Synchronization
请教大家:如何modify java code in order to compilebasic java question
求救求救 JSObject的getWindow为什么总是返回null呀~ant junit and log4j can't work together
Weblogic 8.1又一个问题---应该是有关JDBC的structure in Java??
Re: String newvalue = value.replaceAll("超级菜鸟问题:什末时候load class
问个exception的问题java问题:如何match两个正规表达式
一个简单的关于java Map的问题How to write a file to the same directory of the class file?
最近Code Review看到的奇葩代码Eclipse 编译求助
相关话题的讨论汇总
话题: typeid话题: string话题: gettypeid话题: public话题: myclass
进入Java版参与讨论
1 (共1页)
c**t
发帖数: 26
1
public class myclass
{
private String [] typeId=null;
public myclass(){};
public String [] getTypeId(Res a)
{
int i=0;
for(i=0;i {
if(a[i]!=null)
{
typeId[i]=new String("Levl " + i);
}
}
return typeId;
}
}
调用getTypeId时的a不是空的,但getTypeId返回时出错,说是NullPointerExceptio
c**t
发帖数: 26
2
即使把getTypeId写成下面这样,还是返回空
public String [] getTypeId()
{
typeId[0]="I";
typeId[1]="2";
return typeId;
}

【在 c**t 的大作中提到】
: public class myclass
: {
: private String [] typeId=null;
: public myclass(){};
: public String [] getTypeId(Res a)
: {
: int i=0;
: for(i=0;i: {
: if(a[i]!=null)

P****y
发帖数: 707
3
need initiate the size of the string array?

【在 c**t 的大作中提到】
: public class myclass
: {
: private String [] typeId=null;
: public myclass(){};
: public String [] getTypeId(Res a)
: {
: int i=0;
: for(i=0;i: {
: if(a[i]!=null)

c**t
发帖数: 26
4
可size是变的呀,决定于a.length

【在 P****y 的大作中提到】
: need initiate the size of the string array?
z****g
发帖数: 2497
5
Didn't initializee typeId array.
Modification below:

/// Init typeId
typeId = new String[a.length];
// BTW, what is Res? can it call a.length?

【在 c**t 的大作中提到】
: public class myclass
: {
: private String [] typeId=null;
: public myclass(){};
: public String [] getTypeId(Res a)
: {
: int i=0;
: for(i=0;i: {
: if(a[i]!=null)

1 (共1页)
进入Java版参与讨论
相关主题
Eclipse 编译求助Re: String newvalue = value.replaceAll("
jmock ?? or any other mocking tools?问个exception的问题
面试的一些题目一个简单的关于java Map的问题
what is your opinion in this case?最近Code Review看到的奇葩代码
库里有一个函数名也叫TimeRe: Question: Java Synchronization
请教大家:如何modify java code in order to compilebasic java question
求救求救 JSObject的getWindow为什么总是返回null呀~ant junit and log4j can't work together
Weblogic 8.1又一个问题---应该是有关JDBC的structure in Java??
相关话题的讨论汇总
话题: typeid话题: string话题: gettypeid话题: public话题: myclass