COMP 202 Lecture 15: COMP 202 - Lecture 15 - Oct 7, 2016

14 views3 pages
jc123 and 40170 others unlocked
COMP 202 Full Course Notes
100
COMP 202 Full Course Notes
Verified Note
100 documents

Document Summary

String s = pumpkin; int n = s. length(); char c = s. charat(3); char d = (char) c+1; //no parentheses so only c is being cast to itself error. 7 (pumpkin has 7 letters in it) If you do it properly char d = (char) (c+1) q. In java, we have access to a string datatype. Strings are essentially just sequences of characters of arbitrary length. public static void main(string[] args){ String s = password; boolean b = s==args[0]; Because they are stored in different places in the computer. Now: instead of ==, use . equals() public static void main(string[] args){ String s = password; boolean b = s. equals(args[0]); If there is something that we repeat, that we would like to repeat many times, we can put a loop inside of a loop! Note that we already (sort of) did this when we wrote the method that printed the first n prime numbers!

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents