> Specifically, change the cast to:
>
> CustDB = (ArrayList<?>)read.readObject();
>
> you'll probably have to add some more casts later on in your code in
> addition to making this change.
Thanks for the reply.
I dont quite get what you mean. I am precisely doing what your post listed
CustDB = (ArrayList<?>)read.readObject();
but the warning msg just won't get away.
> In general, don't supply generic type arguments in cast expressions.
Sorry I do not know what's generic, mind to explain?
Oliver Wong - 04 Oct 2006 19:58 GMT
>> Specifically, change the cast to:
>>
[quoted text clipped - 10 lines]
>
> but the warning msg just won't get away.
Are you sure? In your original post, you said you wrote:
CustDB = (ArrayList<Customer>)read.readObject();
But I'm telling you to write:
CustDB = (ArrayList<?>)read.readObject();
Notice that I don't pass "Customer" as a generic type argument.
>> In general, don't supply generic type arguments in cast expressions.
>
> Sorry I do not know what's generic, mind to explain?
To put it informally, generic type arguments are the stuff that appear
between the angle brackets in your code. If you don't understand how they
work, it's probably best not to use them at all (remove everything between
the angle brackets, and the angle brackets themselves), so the code would
look like:
CustDB = (ArrayList)read.readObject();
instead of
CustDB = (ArrayList<Customer>)read.readObject();
You'll get warnings about not using generics, but you should just ignore
them, since you don't know how to use generics yet.
- Oliver
> Specifically, change the cast to:
>
> CustDB = (ArrayList<?>)read.readObject();
Or add a @SuppressWarnings("unchecked") annotation to the method.
sunbin - 04 Oct 2006 19:04 GMT
> Or add a @SuppressWarnings("unchecked") annotation to the method.
Well how do I add that to my codes... sorry i cannot understand the
@suppress thingy.
Tor Iver Wilhelmsen - 04 Oct 2006 19:40 GMT
> Well how do I add that to my codes... sorry i cannot understand the
> @suppress thingy.
Annotations is another of the new JSE 5 features, like the generics
you already use.
http://www.oracle.com/technology/pub/articles/hunter_meta.html
sunbin - 05 Oct 2006 14:07 GMT
>> Well how do I add that to my codes... sorry i cannot understand the
>> @suppress thingy.
[quoted text clipped - 3 lines]
>
> http://www.oracle.com/technology/pub/articles/hunter_meta.html
Hey thanks. I got manage to suppress the warning message.