COMP 202 Lecture Notes - Lecture 15: Cartesian Coordinate System, Data Buffer, Parsing
jc123 and 40170 others unlocked
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
Comp202 lecture 15 scanners, random and intro to oop. Multidimensional array review: int[][]multtable = {{1,2,3,4}, {2,4,6,8}, {3,6,9,12}}; System. out. println(multtable[1]); will print a reference. System. out. println(multtable[1][0] + multtable[2][3]); will print 14. Scanner provides methods for inputting words, numbers, and other data. Scanner is part of the java. util package. Before using scanner it is useful to import it: By convention, all import statements are at the beginning of the file, outside the class. Scanner in = new scanner(system. in); Eg. using the nextint method hasnextdouble(): returns true if the next token can be interpreted as a. This can be prevented by checking the input before parsing it. We can use hasnextint() or hasnextdouble() to do this. When obtaining input via a scanner, the values are stored in a temporary location before being copied into your program. Sometimes, this storage area isn"t emptied properly. When this happens, you will observe odd/undesirable behaviour in your code.