-5

I am given the string "23 45" I need to get 2 variables (int a) with the value 23 and (int b) with value 45

2

1 Answer 1

5

if your input String name is ' in ' , then we will have :

String in = "23 45";

String s[] = in.split(" "); 

int out[] = new int[s.length]; 

for(int i = 0 ; i < s.length ; i++) 

     out[i] = Integer.parseInt(s[i]);

output is now in out array

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.