next up previous
Next: Documentation Up: Assignment 7: Strings and Previous: Assignment 7: Strings and

Experiments!

In lecture we talked about various ways chars, Strings and ints get combined, but we haven't quite filled in the details.

1.
Create a new project named Test.prj, based on the cs151HelloStationery.

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? (How can you determine 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.

5.
Read Section 7.9.1. Type in the code there and see if you can figure out what is going on.


next up previous
Next: Documentation Up: Assignment 7: Strings and Previous: Assignment 7: Strings and
Allen B. Downey
1999-10-19