public interface Iterable{ java.util.Iterator iterator(); }
LinkedList<String> list = new LinkedList<String>(); Iterable<String> iterable = list;
for (E variable: Iterable<E>) {
// can use "variable" in the loop
}
String a = new String("foo");
String b = new String("foo");
if (a == b) {
System.out.println("two different objects are equal! Something is wrong");
}
if (a.equals(b)) {
System.out.println("foo is equal to foo. Life is good");
}
int x = 3; m(x);The value of x is still 3 after the call, no matter what m does.
LinkedListx still refers to the original linked list (not the new list) after the call.x = new LinkedList (); ... m(x); ... void m(LinkedList parameter) { parameter = new LinkedList (); }
LinkedListafter this call, x refers to the same list, which now has a new element.x = new LinkedList (); ... m(x); ... void m(LinkedList parameter) { parameter.add(13); }