Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Ritz05
Contributor
Contributor

Getting exception for String Array variable in tJavaFlex

Hi Team,

I am geeting java.lang.ArrayIndexOutOfBoundsException: error for below code in tJavaFlex.my input row size is 2.

0695b00000fIpFWAA0.png

basically i wan to collect value of Key column from DB input into a array of string.Please suggest.

Labels (3)
1 Reply
rhall1
Contributor III
Contributor III

You can't change the size of an array after it has been created. You have created the array to have one element in your code in the "Start Code" section. If you know that there will be 2 rows coming into this JavaFlex, you will need to create your array as follows.....

 

String[] PrimaryKeyList = new String[2];

 

If you do not know the size of your array, you can use the java.util.ArrayList class. You can add to this without knowing the total number of elements. If you need an array out of this, you can convert it to an array by doing something like this....

 

ArrayList<String> PrimaryKeyList = new ArrayList<String>();

//Add to the array with any number of values

//To get the values converted to an array, do the following...

String[] array = PrimaryKeyList.toArray(new String[PrimaryKeyList.size()]);