wood burning stoves*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Generics Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Generics Questions" Watch "Generics Questions" New topic
Author

Generics Questions

Ste Graham
Greenhorn

Joined: Sep 15, 2003
Posts: 23
With one thing and another (e.g. getting married) I took a break from the developer exam. I've just recently restarted and I'm ready to submit BUT when I originally started I was using Java 1.4. Obviously, I have to test and compile the code with 1.5 now. It's first time I've tried this and I'm getting errors when compiling about the use of generics in collections i.e:

"Sime Input files use unchecked or unsafe opertaions"

If I run the compile with -xlinit:unchecked argument i see the problematic lines. Up until now I haven't really used Java 1.5, and so generics is new to me. At the moment, even though I get the message when compiling, every things works fine without - do I need to alter my code to accomodate generics? Or can I leave as is?

Ste :-)
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
I started out using 1.4 a month ago and decided to recompile and release it using 1.5. Since you use casting anyway for 1.4 collections, your app should run as is. I fix mine to get rid of the warnings but those are warnings about possible invalid cast.
Ste Graham
Greenhorn

Joined: Sep 15, 2003
Posts: 23
Thanks Mike.

If i don't re-code to deal with the generics issue, do you think I need to document this in my choices.txt file? I mean the reason i don't want to do it is because as far as I was aware I'd finished and don't want to be bothered to have go though the code changing stuff everywhere!!! Lazy, I know!!
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89
If i don't re-code to deal with the generics issue, do you think I need to document this in my choices.txt file? I mean the reason i don't want to do it is because as far as I was aware I'd finished and don't want to be bothered to have go though the code changing stuff everywhere!!! Lazy, I know!!


Actually if you don't recode then your code is backward compatible with older
version of the jdk. Unless the grader recompiles your code or reading the source code, he/she would not be able to tell. It's up to you to mention it but I don't see it as a big issue.
I kept my code in cvs so I can get back the older version.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
You should always thrive for your code to compile without any warnings.

If I were an assessor I'd subtract points for compiler warnings, probably quite a few too if they were as easily avoidable as the ones you're talking about.


42
Mike Ngo
Ranch Hand

Joined: Oct 16, 2006
Posts: 89

You should always thrive for your code to compile without any warnings.

If I were an assessor I'd subtract points for compiler warnings, probably quite a few too if they were as easily avoidable as the ones you're talking about.


It depends... There are tons of existing code in production that simply cannot be fixed just for compiler warnings.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
That's existing code. You're however producing new code, and there is no excuse for compiler warnings in new code.

Whether you wrote it a year ago or not doesn't matter, it's not been delivered so it's new code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Generics Questions
 
Similar Threads
Generics: warnings
generics
Generics Help
Generics
Generics