lecture-23a - Standard Input • Once the BufferedReader...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 34 Standard Input • Once the BufferedReader object is established, its readLine method is used to read a single line of text as a String • Pressing the Enter (or Return) key signals the end of line String bean; System.out.print(“What is your favorite coffee bean? ”); bean = bufReader.readLine( ); System.out.println(bean + “ is on sale for $4.99 per lb”);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 35 Sample interaction using System.in and System.out .
Background image of page 2
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 36 Standard Input • To input a primitive data type, say, int String inputStr; int age; System.out.print(“Enter age: ”); inputStr = bufReader.readLine(); age = Integer.parseInt(inputStr);
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Object Oriented Programming Numerical Data R.B. Lenin Winter - 2006 DA-IICT 37 Standard Input • Calling the readLine method can result in an error condition called an
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course CSE IT115 taught by Professor Rblenin during the Spring '10 term at Punjab Engineering College.

Page1 / 15

lecture-23a - Standard Input • Once the BufferedReader...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online