Scanner scanner = new Scanner(System.in); String input = scanner.nextLine(); input = input.substring(1, input.length() - 1); if(input!=""){ String[] strNums = input.split(", "); int[] nums = new int[strNums.length]; for(int i=0;i<nums.length;i++){ nums[i]=Integer.parseInt(strNums[i]); } System.out.println(handle(nums)); } else { System.out.println(0); }