Using Scanner in ArrayList String and how can it be used for getting inputs of any types? description has also a type of error please help me to rectify it?

Using a Scanner with the ArrayList??ArrayList Contains string Elements??
Scanner scan = new Scanner(System.in);
ArrayList list = new ArrayList();
while(scan.hasNextInt()){
list.add(scan.next());
}
String[] num = list.toArray(new String[charAt(0)]);
for(int i = 0; i < num.length; i++){
System.out.println(num[i]);
}
how to change string Arraylist to a Integer??

What error are you facing exactly?
We can use scanner with arraylist and an arraylist can contain string as elements, if thats your concern.

.
I also want to ask if we could change string ArrayList to Integer ArrayList?

You’ll have to declare a new ArrayList.
There’s no direct method to convert it.