+ 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
5 odpowiedzi
+ 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.
+ 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
+ 3
Devishree
Additional info, here are the reference pages for String.split() and Integer.parseInt()
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)
https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#parseInt-java.lang.String-
+ 2
Jayakrishna🇮🇳 Ipang Thanks a lot 🤗
+ 1
Ipang Java