Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎notes‎ > ‎

2017-09-19 HW

posted Sep 19, 2017, 9:37 AM by Samuel Konstantinovich   [ updated Sep 19, 2017, 9:37 AM ]
Regarding Strings, you really need the following:
1 charAt(int)
2 length()
3 equals(String)
4 compareTo(String)
5 indexOf(String)
6 substring(int,int)
7 substring(int)
When you read the java documentation, pay attention to when they throw exceptions (runtime errors), and when they return special values. 


Here is the AP subset of Java you need to know:
Strings are here:


Goal: For Loops!

int x = 0; //initialize

while (x<10){     //check

//body

x++;       //increment

}


equivalent to this is:

for(int x = 0; x<10; x++){

//body

}


Basic syntax for a "for" loop:

for(variable; check; increment){

//body

}


However, when you declare a variable inside of a "for" loop, it will not be defined outside of the function.

 - If you define the variable, x, outside of the "for" loop, you will be able to use it both in the "for" loop and outside of it.


In a "while" loop, there is much flexibility inside of the body, where the parts such as the increment and body can be scrambled.

On the other hand, in "for" loops, the format is much stricter.



Classwork / HW
String-2
prefixAgain 
xyzMiddle 
getSandwich 
sameStarChar 
oneTwo 
zipZap

String-3:
CountTriple
SumDigits
Comments