on 07-09-2009 8:19 PM
Hi all. im doing a UDF wich no have sintax error but when i execute it if fails. i try yo simulate it in another app. and the error is this. run:
Exception in thread "main" java.lang.NullPointerException
at javaapplication2.Main.main(Main.java:28)
here is the UDF code:
int i_correlativo;
String[] flags = null;
String[] ArrayFlags = null;
ResultList result = null;
ArrayFlags[0] = "85";
ArrayFlags[1] = "86";
ArrayFlags[2] = ResultList.CC;
//Recorro cada posicion del arrayFlags para determinar el valor de los Flags.
try{
for (int j = 0; j < ArrayFlags.length - 2; j++){
if (!(ArrayFlags[j].equals(ResultList.CC))) {
i_correlativo = 85;
for (int i = 0; i < 8; i++) {
if (ArrayFlags[j].equals(String.valueOf(i_correlativo))) {
flags<i> = "1";
i_correlativo++;
} else if (!(flags<i>.equals("1"))) {
flags<i> = "0";
i_correlativo++;
}
}
} else {
for (int x = 0; x < flags.length; x++) {
result.addValue(flags[x]);
}
result.addContextChange();
}
}
}catch(Exception e){
System.out.println(e);
}
Thanks A Lot.
RP
Hello,
Your exception Nullpointer raises when ever you are assinging varables wrongly.The following statements are causing the problem.
String[] flags = null;
String[] ArrayFlags = null;
ArrayFlags[0] = "85";
ArrayFlags[1] = "86";
ArrayFlags[2] = ResultList.CC;
Here you are assigning to array variables with out creating object for String array.You need to create objects for the array statements like
String[] flags =new String[<specify the length>] (eg:- String[] flags =new String[3] )
String[] ArrayFlags =new String[<specify the length>]
The another statement
flags = "1";
you have declared 'flags' as String Array, and you are assigning it like normal varaible. Use index like flags[0]="1" .
Check these cases, which causes NullPointerException.
Regards,
Prasanna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Rodrigo,
In the code first of all we dont use System.out.println(e);
Instead you can use:
AbstractTrace trace=container.getTrace();
trace.addWarning("give the variablename and value here");
Also can you tell what you are trying to do with this udf.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.