COMP SCI 302 Lecture Notes - Lecture 3: Whitespace Character, Data Type, Decimal Mark

27 views2 pages

Document Summary

Data type char - each letter in a string is a char (one char is 2 bytes or 16 bits) 2: stream stores key presses (called buffer) Integer (representing character pressed) is produced: only until enter key is pressed. Methods used with scanner nextline() - a method that returns a string of chars up until newline character is reached. It removes characters from the buffer (temp storage). Also removes newline character (\n). next() - a method that skips whitespace and returns a string of characters up until a whitespace character. Also removes characters and whitespace characters (excepts last whitespace character). String ans = scnr. nextline(); nextint() - a method that skips whitespace and returns chars up to, but not including whitespace as an int. Leaves last whitespace character in buffer. nextdouble() - a method that skips whitespace and returns chars up to, but not including whitespace as a double. Words - spaces are recognized as a break between words.

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