Ok if I have an string input of “3 6”
how do I put those two int in an array? what if you have more than one spaces between them?
let’s say I want those numbers to be in an array like {3, 6}
is that possible? thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this, using a regular expression to split the input string whenever a sequence of one or more spaces is found, and then convert the resulting
String[]to anint[]:Now the
intsarray contains the expected values: