sangeeta sabharwal

Greenhorn
+ Follow
since Jul 25, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by sangeeta sabharwal

Thanks. That makes sense as it is a conscious decision of the compiler !!
12 years ago
They will become tightly coupled only you expose internal working of the second module to the first module or expose attributes for direct access. If the module is doing database update, the Client should not be calling it.
12 years ago


Line 1 works fine
why does Line 2 needs an explicit cast like in line 3

12 years ago
Thanks. Won't say its absolutely clear .... I think I will need to read and try type erasure in detail to understand it completely. Have some idea for now.


12 years ago
By the type erasure logic....even this should have worked. But this gives an error, as it rightly should.

import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;


public class TestCollection {
public static void main(String args[]) {
Collection<Integer> collection = new ArrayList<Integer>();
collection.add("ab");

collection.add(2);
collection.add(3);
Iterator<Integer> iterator = collection.iterator();
while(iterator.hasNext())
System.out.print(iterator.next());
System.out.println(collection);

}
}
12 years ago
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;


public class TestCollection {
public static void main(String args[]) {
Collection collection = new ArrayList<Integer>();
collection.add("ab");

collection.add(2);
collection.add(3);
Iterator<Integer> iterator = collection.iterator();
while(iterator.hasNext())
System.out.print(iterator.next());
System.out.println(collection);

}
}

Why is this allowed ? The program after warning goes on to print
ab23[ab, 2, 3]

12 years ago