Imperative Finale
> Click or hit Control-Enter to run the code above
Casting
If you want to force Java to convert a variable from one type to another you can try applying a cast.
int i = 10;
double d = i; // This works since no information is lost
i = d; // This does not work since we'd have to throw out the fraction
i = (int) d; // But we can force Java to do it
> Click or hit Control-Enter to run the code above
Most Common Character
Imagine I have a string and want to determine which character appears most.
Write a function that returns the most common character.
What’s Our Algorithm?
Searching is OK
(Just don’t search for or use "Solution to CS 125 MP2".)
> Click or hit Control-Enter to run the code above
Announcements
-
Quiz 3 starts today in the CBTF. It covers multi-dimensional arrays and more about functions.
-
TC 7 will be out shortly and due Sunday by midnight.
-
MP2 is due today! Office hours until 5PM today.
-
MP3 will be out today and due in two weeks. It’s your introduction to object-oriented programming, so don’t expect to begin it until next Monday when we start talking about objects.