COE 318 Lecture 2: ScannerClassDemo

52 views2 pages

Document Summary

Bufferedreader objreader = new bufferedreader public class scannerphrasein public static void main (string[] args) throws ioexception. Scanner freader = new scanner(line); // create a scanner object. //loop for as long as there are input lines. while (freader. hasnext()) // true if another token is available word = freader. next(); // fetch next token newword = word. concat(doh); // manipulate token. Methods that test for availability of legal input for loops, optional elements, error checking. = sc. hasnext() true if another token is available to be read. = sc. hasnextint() true if another int is available to be read. = sc. hasnextdouble() true if another double is available to be read. = sc. hasnextxyz() xyz stands for one of the input types available above. // the bufferdemo class public class bufferdemo public static void main (string [] args) // create an empty stringbuffer, a string that holds. // computer, a string that holds world and an. // add the string to the buffer newphrase. append (word);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions