Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public static int unlimitedArrayEntries() { //in this case returning their sum
  2. Scanner in = new Scanner(System.in);
  3. String result = "";
  4. int sumOfEntries = 0;
  5. while (in.hasNextInt()) {
  6. result = result + in.nextLine() + " ";
  7. }
  8. String[] output = result.split(" ");
  9. // do stuff with output[indecies like summing them up
  10. for (int i = 0; i < output.length; i++) {
  11. sumOfEntries += Integer.parseInt(output[i]);
  12. }
  13. return sumOfEntries;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement