I am creating my first extension in which I am spliting a text after text spliting It convert into a string arraylist but I have to do some maths with them but I am facing somme error the error is String arraylist cant be converted into int arraylist please help me how can I convert String arraylist int int arraylist
All are here for helping each other so please do not tag anyone firstly
The error is saying you cannot convert a String array list to integer array list for this you have to parse your string to int by using loop like this
// creating String array list
String[] stringlist = {"1","2","3","4","5"};
// Creating new integr array list of size 5
int[] integerlist = new int[5];
// Using for loop for parsing the integer from string
for (int i=0;i<stringlist.length;i++) {
// parsing integer by Integer.parseInt(string)
integerlist[i]=Integer.parseInt(stringlist[i]);
// printing converted int
System.out.println(integerlist[i]);
}
In this you can see I am using Integer.parseInt() method to parse string in to integer
Hope this helps you