How to convert string list into int list

Hello everyone

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

Please help @Sumit1334

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

3 Likes

Will this work in my extension

Hahah what are you saying if this will not work then why will I gives you
Have you tried it

Why have you write their System.out.println in your code

It is code for printing in java
Do not code this in your extension

Thank you @Sumit1334

it works thank you very much

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.