package work; import java.util.*; public class Work { public static void main(String args[]) { ArrayList a = new ArrayList<>(); Random r = new Random(); int n=5, j, b, s=0; for (j = 0; j < n; j++) a.add(r.nextInt(20)); System.out.println(a); for (j = 0; j < n; j++) { b=a.get(j); while (b > 0) { s += b%10; b = (b-b%10)/10; } } System.out.println(s); } }