+ 1

How to split a string ,containing two or more integers seperated by comma, into two or more integers.

Eg, String str = "16,20,24"; Convert this string such that we get int a = 16 int b = 20 int c = 24

24th Nov 2022, 1:59 PM
Devishree
Devishree - avatar
5 Réponses
+ 4
String s[] = str.split(","); will returns array of strings, splitted by comma from str string. Store it in a string array. Integer.parseInt( "20" ) ; will return integer type value 20 from string type "20". So if you store in array s[] then linearly convert all string value into integer type as Integer.parseInt( s[0] ); store it in int type. Hope it helps.
24th Nov 2022, 2:24 PM
Jayakrishna 🇮🇳
+ 4
That would most likely depend on the language in relevance. Please specify the relevant programming language(s) in your post tags (Edit) Post tags updated. https://code.sololearn.com/W3uiji9X28C1/?ref=app
24th Nov 2022, 2:06 PM
Ipang
24th Nov 2022, 2:29 PM
Ipang
+ 2
Jayakrishna🇮🇳 Ipang Thanks a lot 🤗
24th Nov 2022, 3:42 PM
Devishree
Devishree - avatar
+ 1
Ipang Java
24th Nov 2022, 2:08 PM
Devishree
Devishree - avatar