String line = console.readLine()
StringTokenizer st = new StringTokenizer(line)
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens()
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken()
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false tokenizer is empty (but line is untouched)
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false thus st = new StringTokenizer(line) allows us to reprocess the string (if we need to)
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false thus st = new StringTokenizer(line) allows us to reprocess the string (if we need to)
String line = console.readLine() StringTokenizer st = new StringTokenizer(line) st.hasMoreTokens() true String token = st.nextToken() process the token somehow false thus st = new StringTokenizer(line) allows us to reprocess the string (if we need to) // sum is defined and initialized to zero outside try { int number = Integer.parseInt(token); sum = sum + number; } catch (Exception e) { System.out.println(token + “ not a number!”); }