Jump to content
Sign in to follow this  
  • entries
    455
  • comments
    639
  • views
    424517

Reason to hate java #4789

Sign in to follow this  
_the_phantom_

113 views

Quote:

Note: Some input files use unchecked or unsafe operations.



public BugReport getBugReport(int inPos) {

if(inPos < bugReports.size()) {
return (BugReport)bugReports.elementAt(inPos);
}
return null;
}


yes, I know, I told it todo them... so give me a safe option... oh, wait, you cant.

*misses templates*

Sign in to follow this  


4 Comments


Recommended Comments

technically, nowt, the vector object "bugReports" stores everything as an object, so to get it back to the BugReport object you have to cast it.. the compile complains that this is unchecked/possibly unsafe...

Share this comment


Link to comment
Ah, okay... that whole casting thing becomes so normal in Java that I failed to see anything wrong [lol]

I've not used the "Java 5" series - IBM were on Java 1.4.2 (i think) which was where I last did any serious Java programming. Is that warning some sort of by product of how they have their generics thing? I don't remember the 1.4.2 compiler ever complaining about that sort of thing.

Jack

Share this comment


Link to comment
You should check out java 1.5, it has generics.

Though, I prefer templates (C++ templates), I don't care about having multiple copies of basicly the same thing but with class T replaced with double or char, as long as I don't have to do it.;P

Your code would become:

public BugReport getBugReport(int inPos) {

if(inPos < bugReports.size()) {
return bugReports.elementAt(inPos);
}
return (BugReport)null;
}

:P

But your declaration of bugReports would be: vector<BugReport> bugReports.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!