Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int unlimitedArrayEntries() { //in this case returning their sum
- Scanner in = new Scanner(System.in);
- String result = "";
- int sumOfEntries = 0;
- while (in.hasNextInt()) {
- result = result + in.nextLine() + " ";
- }
- String[] output = result.split(" ");
- // do stuff with output[indecies like summing them up
- for (int i = 0; i < output.length; i++) {
- sumOfEntries += Integer.parseInt(output[i]);
- }
- return sumOfEntries;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement