String line = console.readLine() StringTokenizer st = new StringTokenizer(line)

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

For(int i = 1; i
Chapter 5 Functional Methods. © Daly and Wrigley Learning Java through Alice Objectives Properly construct and use methods when programming. Describe.
Bit Manipulation. Binary Numbers Base 10 numbers are represented by sum of digits times powers of 10. For example: 234 = 2* * *10 0 Binary.
Lab1: File I/O and Streams Lecturer: Mauro Conti T.A.: Eyüp S. Canlar.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Applications of Stacks Direct applications Delimiter matching Undo sequence in a text.
1 Powers of Two: Trace Ex. Print powers of 2 that are  2 N. Increment i from 0 to N. Double v each time. int i = 0; int v = 1; while (i
Using Processing Stream. Predefined Streams System.in InputStream used to read bytes from the keyboard System.out PrintStream used to write bytes to the.
Input Output Examples. import java.io.*; class Greetings { public static void main (String[] args) { try { DataInputStream in = new DataInputStream(System.in);
Exception examples. import java.io.*; import java.util.*; class IO { private String line; private StringTokenizer tokenizer; public void newline(DataInputStream.
1 String Buffer & String Tokenizer Overview l Overview of String Buffer class and Methods l Overview of String Tokenizer class and methods l Preview: Notions.
ITERATION CSC 171 FALL 2004 LECTURE 10. Simple Branching If (test){ A;} start end A; test.
Yenta A Simple Recommendation Language Kenny Rivera - Tester Becky Tang – System Architect Shylah Weber – Systems Integrator Anthony Yim – Project Manager.
23-Jun-15 Strings, Etc. Part I: String s. 2 About Strings There is a special syntax for constructing strings: "Hello" Strings, unlike most other objects,
Java Collection Framework. Interface Collection add(o) Add a new element clear() Remove all elements contains(o) Membership checking. IsEmpty() Whether.
Fundamental Programming Structures in Java: Strings.
Lecture 171 CS110 Lecture 17 Thursday, April 1, 2004 Announcements –hw7 due tonight –pass/fail, withdraw deadline April 8 Agenda –Questions –Juno –JFile.
Strings, Etc. Part I: Strings. About Strings There is a special syntax for constructing strings: "Hello" Strings, unlike most other objects, have a defined.
SELECTION CSC 171 FALL 2004 LECTURE 8. Sequences start end.
PROXY Matt Burden T-Kiang Tan Proxy (prok-se): An agent or substitute authorized to act for another SourceSource: Webster's Revised Unabridged Dictionary,
General Computer Science for Engineers CISC 106 Lecture 33 Dr. John Cavazos Computer and Information Sciences 05/11/2009.
Chapter 91 Streams and File I/O CS-180 Recitation-03/07/2008.
1 Infinite Loops  The body of a while loop eventually must make the condition false  If not, it is an infinite loop, which will execute until the user.
Special Sum The First N Integers. 9/9/2013 Sum of 1st N Integers 2 Sum of the First n Natural Numbers Consider Summation Notation ∑ k=1 n k =
Bkevil Solve Equations With Variables on Both Sides.
Chapter 16 – Files and Streams. Goals To be able to read and write text files To be able to read and write text files To become familiar with the concepts.
Web Security Programming I Building Security in from the Start Except where otherwise noted all portions of this work are Copyright (c) 2007 Google and.
Java Utility Classes CS 21b. Some Java Utility Classes Vector Hashtable StringTokenizer * import java.util.*;
Number Triples An Investigation Number Triples A number triple consists of three whole numbers in a definite order. For example (4, 2, 1) is a triple.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University Investigation.
BPJ444: Business Programming Using Java – String Handling Tim McKenna
SOLVE EQUATIONS WITH VARIABLES ON BOTH RED CARD- NO SOLUTION YELLOW CARD- 1 SOLUTION GREEN CARD-INFINITE SOLUTIONS bkevil.
Do Now: Factor x2 – 196 4x2 + 38x x2 – 36 (x + 14)(x – 14)
Lecture 14 March 23, Exam Results Class Average was 69.4 –Median was 72.5 (which means there were some very low grades) Questions 31, 32, and 33.
1. 3 x = x 3 2. K + 0 = K (3 + r) = (12 + 3) + r 4. 7 (3 + n) = n Name the Property Commutative of Multiplication Identity of Addition.
Computer Programming 2 Lecture 5: String Processing Part b: Class StringTokenizer Prepared & Presented by: Mahmoud Rafeek Alfarra MINISTRY OF EDUCATION.
1 StringTokenization Overview l StringTokenizer class l Some StringTokenizer methods l StringTokenizer examples.
Introduction IS Outline  Goals of the course  Course organization  Java command line  Object-oriented programming  File I/O.
Lab 2 Primer Assignment 3 Structure File I/O More parsing and HTTP Formatting.
Java Programming Java Basics. Data Types Java has two main categories of data types: –Primitive data types Built in data types Many very similar to C++
Announcements Final Exam:TBD. public static void main(String [] args) { final int ASIZE = 5; int [] intArray= new int[ASIZE]; for(int i = 0; i < ASIZE;
Files and Streams CS /02/05 L7: Files Slide 2 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
Java for C++ Programmers A Brief Tutorial. Overview Classes and Objects Simple Program Constructors Arrays Strings Inheritance and Interfaces Exceptions.
If Statement if (amount
Chapter 9 1 Chapter 9 – Part 2 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
 When a conditional and its converse are both true, we combine them to make a biconditional.  Example:  Biconditional – An angle is right if and only.
Chapter One Lesson Three DATA TYPES ©
A: A: double “4” A: “34” 4.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stacks2 Abstract Data Types (ADTs) An abstract data type (ADT) is an abstraction of a data.
Iteration & Loop Statements 1 Iteration or Loop Statements Dept. of Computer Engineering Faculty of Engineering, Kasetsart University Bangkok, Thailand.
Lesson 1.2 Inductive Reasoning Pages Observe Look for patterns Develop a hypothesis (or conjecture) Test your hypothesis.
Sum of Arithmetic Sequences. Definitions Sequence Series.
Object-Oriented Programming (Java) Review Unit 1 Class Design Basic Console I/O StringTokenizer Exception UML class diagram.
Rational Inequality: Solving Algebraically
Chapter 2 Reference Types. Class : Point2D class Point2D { private double x,y; public Point2D(double xx,double yy) { x = xx ; y = yy ;} public void setX(double.
Overview Project 2 JFileChooser StringTokenizers Vectors/arrays.
© 2004 Goodrich, Tamassia Stacks. © 2004 Goodrich, Tamassia Stack: Last In First Out (LIFO).–Used in procedure calls, to compute arithmetic expressions.
CS202 Java Object Oriented Programming Input and Output Chengyu Sun California State University, Los Angeles.
What If? Write a program that prompts for the names and locations of 1000 employees. Store the information in the program for later use.
Review Operation Bingo
The Total Record Catches For Hines Ward
Chapter 5 Stacks and Queues 11/28/2018 Stacks.
Welcome back to Software Development!
Stacks.
Chapter 13 Exception Handling: A Deeper Look
Solve Equations With Variables on Both
File Input and Output.
Compiler Construction
Properties of Operations
Presentation transcript:

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!”); }