daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Nov 20th, 2017 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class sumOfNumbers {
  2.     public static void main(String[] args) {
  3.  
  4.         String str = "drA234:32Aws";
  5.  
  6.         String[] arrString = str.split("[^0-9]+");
  7.  
  8.         int[] arrNumbers = new int[arrString.length];
  9.  
  10.         for (int i = 0; i < arrString.length; i++) {
  11.             if (!arrString[i].equals("")) {
  12.                 arrNumbers[i] = Integer.parseInt(arrString[i]);
  13.             }
  14.         }
  15.  
  16.         int sum = 0;
  17.  
  18.         for (int a : arrNumbers) {
  19.             System.out.println(a);
  20.             sum += a;
  21.         }
  22.  
  23.         System.out.println(sum);
  24.  
  25.     }
  26. }
RAW Paste Data
Top