cs205: engineering software? |
(none) 20 September 2010 |
cs205 Monday 28 August 2006
Assignments Due |
What are the two possible meanings of an assignment statement (e.g., a = b) in Java?
Excerpts from Java API documentation:
java.lang.String
The String
class represents character strings. All
string literals in Java programs, such as "abc"
, are
implemented as instances of this class.
Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings. Because String objects are immutable they can be shared. For example:
String str = "abc";
is equivalent to:
char data[] = {'a', 'b', 'c'}; String str = new String(data);
public boolean equals(Object anObject)
Compares this string to the specified object. The result is true if and only if the argument is not null and is a String object that represents the same sequence of characters as this object.
public class Strings { public static void main (String [] args) { String s = new String ("hello"); String t = new String ("hello"); StringBuffer sb = new StringBuffer ("he"); StringBuffer tb = sb; String s1 = "hello"; String t1 = "hello"; sb.append ("llo"); tb.append (" goodbye!"); s.concat (" goodbye!"); t = s.concat (" goodbye!"); // What are the values of s, t, sb and tb now? // Which of these are true: // a) s == t // b) s1 == t1 // c) s == s1 // d) s.equals (t) // e) sb == tb // f) t.equals (tb) } }
How does a specification constrain a client?
Our procedural specifications will use three clauses:
requires → (effects & everything that is not listed in modifies is unchanged)What is the point of having a MODIFIES clause?
What are the advantages and disadvangates of formal (instead of
informal) specifications?
If a procedure's specification has no REQUIRES clause, what is the precondition?
If a procedure's specification has no MODIFIES clause, what can it modify?
What does it mean when a procedure has no EFFECTS clause?
Then you should say what you mean, the March Hare went on.
I do, Alice hastily replied; at least--at least I mean what I say--that's
the same thing, you know.
Not the same thing a bit! said the Hatter. You might just as well
say that "I see what I eat" is the same thing as "I eat
what I see"!
You might just as well say, added the March Hare, that "I
like
what I get" is the same thing as "I get what I like"!
You might just as well say, added the Dormouse, who seemed to be
talking
in his sleep,
that "I breathe when I sleep" is the same thing
as "I sleep when I breathe"!
It IS the same thing with you, said the Hatter, and here the
conversation
dropped,
and the party sat silent for a minute, while Alice thought over
all she could remember about ravens and writing-desks, which wasn't much.