i want to extract number and add these numbers using Java and String remain same.
String as-
String msg="1,2,hello,world,3,4";
output should come like- 10,hello,world
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.
Note that the above practice of using exceptions as control flow should be avoided almost always. This concrete case is I believe an exception, because there is no method that verifies the “parsability” of the string. If there was
Integer.isNumber(string), then that would be the way to go. Actually, you can create such an utility method. Check this question.