Tuesday, September 13, 2011

some notes


class MutableString
{
private String data;
String toString() { return data; }
setValue(String x) { data = x; }
String getValue() { return data; }
}


Swap(MutableString a, MutableString b)
{
MutableString t = new MutableString;
t.setValue(a.getValue()); // c = a
a.setValue(b.getValue()); // a = b
b.setValue(t.getValue()); // b = t
}

String a = "hello";
String b = "hi";
if (a.equals(b))
{

}
String s = "";
for (int i = 0; i < 100; i++)
{
s += i;
s += "\n";
}


String s = new String("");
for (int i = 0; i < 100; i++)
{
s += new Integer(i).toString();
}

No comments:

Post a Comment