Arie Prastowo

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

Recent posts by Arie Prastowo

you cannot change context init parameter. (thread safe)
but you can change context attribute (not thread safe)
Hi there,
In method(Collection<T> cs,T t), if you assume T in collection is Object, than, the second argument can be anything from Object to it's subclasses.

Because in runtime, what will happen is the method signature become method(Collection<Object> cs, Object t).
I think that is happen because in JSP, session is never null. It is an implicit object, so I guess HttpServletRequest.getSession() is always called.

Arie Prastowo
if you do not use serialization on parent class, it's attribute will not be serialized no matter you mark it as transient or not.
When you deserialized, the attribute from not serialized parent class will be initialized.
But on serialized parent class, a transient attribute is not serialized or deserialized, so the value is 0 as in default value
thank's for the help. now, It can be found
Does anybody knows where to put jar files in the J2EE Container?
I put it under WEB-INF and WEB-INF/classes, but it still cannot be found.

SCJP 5.0
It is the same as this
Object o=new Integer(5);
Integer i=o; //--> will not compile
After failed on the first trial (back in 2007), today I finally passed the exam with 87%. Actually, there is a little dissappointment because I cannot get more than 90%.
I used KB for nearly a year since my first failure and then a week before taking the exam, I purchased exam mock from enthuware. It is really usefull.
By the way, still confused about next exam should be taken, SCWCD or SCBCD.

SCJP 5.0
15 years ago
List<? extends Object> ls2 = new LinkedList<Object>();
addandDisp(ls2,new Object());

ls2 can be reference of Object or it's subclasses

while the method only received (in this case), Object
if the method signature is like
public static <T> void addandDisp(Collection<T> cs, T t) {}


//call 2
List<? extends Object> ls2 = new LinkedList<Object>();
addandDisp(ls2,new Object());

because you declare
List<? extends Object> ls2
there might be a possibility that the runtime object is of type List<String> since String extend Object.
So, the call will use List<String>,Object.
You cannot apply (List<String>,Object) to (Collection<T>,T) since Object is not the subclass of String
In my understanding
public static <T> void addandDisp(Collection<T> cs, T t)
for (T o : cs)
for (T o : cs)
this method expect a T Collection and T object

//call 1
List<? super Object> ls1 = new LinkedList<Object>();
addandDisp(ls1,new String());
// error free because it will give an Object (include superclasses, if any) Collection and String. Since String is a subclass of Object or whatever is superclasses, calling the method like this will use widening/upcasting.

//call 2
List<? extends Object> ls2 = new LinkedList<Object>();
addandDisp(ls2,new Object());
// will error because the type of ls2 is anything than extends Object inclusive and an Object. Since in the method declaration the parameter cs is not type a Collection of anything than extends Object inclusive, the compiler sees that there is a possibity the type in cs might be different with the type of t. In compile time the compile prevent something like this (Collection<String> cs,Object t)

//call 3
List<Object> ls3 = new LinkedList<Object>();
addandDisp(ls3,new String());
// same as number one it will use widening/upcasting for String class.

//call 4
List<? super Object> ls4 = new LinkedList<Object>();
addandDisp(ls4,new Object());
// same reason as number 1 and 3
when you said C3 IS-A I2, only valid in class definition where C3 IS-A C1 and I2.
But when you declare
static C3 o3;
the compiler expect something that come from C3 or it subclasses.
It would make a different if you code
static I2 o3;
since it can accept anything that implement I2 including o2
Come from additional investigation that when your code:

the compiler expect that one of Test subclasses might implement face and it just compile fine. But that's won't work on final classes, since it will never has subclasses
I have try several other cases and found the following:
1. when you try to cast a non-final class to an interface, it will compile whether or not they are in same hierarchy. But it will throws ClassCastException when it's not in the same hierarchy.
2. the above point won't work on final Class.

Correct me if I'm wrong

In my understanding, you can't do that because o3 was declare as C3 so it expected also C3 and all it's subclasses