0

How to remove a char from string? JAVA

Hello everyone I want to know how can I remove ','s from (for ex.) "42,32,55,77" and add those numbers in an array.

17th Jul 2018, 6:47 PM
Mir-Abgar Abrahamyan
Mir-Abgar Abrahamyan - avatar
4 ответов
+ 2
It's called splitting. String[] parts = myString.split(","); You'll then have to convert the strings to numbers manually if you need to. One way to do it is List<Integer> myListOfNumbers = Arrays.stream(parts).map(Integer::parseInt).collect(Collectors.toList());
17th Jul 2018, 9:03 PM
Schindlabua
Schindlabua - avatar
+ 1
String Str = new String("1,2,3,4,5"); Str = Str.replace(',', ''); //it's for remove ','
17th Jul 2018, 7:34 PM
Ivanov Ilya
Ivanov Ilya - avatar
0
What about array?
17th Jul 2018, 7:38 PM
Mir-Abgar Abrahamyan
Mir-Abgar Abrahamyan - avatar
0
oh I have founded the split and wanted to ask about making them integers and I have got this message. Thanks a lot guys!
18th Jul 2018, 9:06 AM
Mir-Abgar Abrahamyan
Mir-Abgar Abrahamyan - avatar