COMP 202 Lecture 15: COMP 202 - Lecture 15 - Oct 7, 2016
jc123 and 40170 others unlocked
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!