Next: Palindromes
Up: Assignment 7: Strings and
Previous: Assignment 7: Strings and
In lecture I talked about various ways that chars, Strings
and ints get combined, and we made a couple of guesses about
what Java does.
- 1.
- Create a new project named Test (no graphics).
- 2.
- In main, write some simple expressions that combine
various types using the + operator. For example, what
happens when you ``add'' a String and a char?
Does it perform addition or concatenation? What is the type
of the result?
- 3.
- Make a big copy of the following table and fill it in. At each
intersection, you should indicate what operation is performed
(addition or concatenation), and what the type of the result is.
| |
boolean |
char |
int |
String |
| boolean |
|
|
|
|
| char |
|
|
|
|
| int |
|
|
|
|
| String |
|
|
|
|
- 4.
- Think about some of the choices the designers of Java
made when they filled in this table. How many of the entries
seem reasonable, as if there were no other reasonable choice?
How many seem like arbitrary choices from several equally
reasonable possibilities? How many seem stupid?
You don't have to write answers to any of those questions,
but you can if you want.
Next: Palindromes
Up: Assignment 7: Strings and
Previous: Assignment 7: Strings and
Allen B. Downey
1999-03-17