Results 1 to 3 of 3
  1. #1
    castiel is offline Member
    Join Date
    Aug 2009
    Posts
    26
    Rep Power
    0

    Default Generics Differences?

    Hey I was just wondering what's the difference between these two generics statements?

    Java Code:
     Vector<String> v = new Vector<String>();
    	
    	Vector<String> v2 = new Vector();

    What I'm not 100% clear on is in what situation would you have generics on the right side of the equals operator. Could someone please give me an example of where such a thing may be used.

    Cheers,
    newbie

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by castiel View Post
    Hey I was just wondering what's the difference between these two generics statements?

    Java Code:
     Vector<String> v = new Vector<String>();
    	
    	Vector<String> v2 = new Vector();

    What I'm not 100% clear on is in what situation would you have generics on the right side of the equals operator. Could someone please give me an example of where such a thing may be used.
    Ignore the previous poster please; it's just a kid, raving mad and his posts will hopefully removed soon.

    The second initialization only exists for backwards compatibility reasons; it creates a raw type and assigns it to a generic type. Alsways try to use the first form if you want to play it by the rules.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by AnyJavaPros View Post
    Yo jos ass hole, you are the imposter, noob. fuck yourself la, your mother must be sleeping with other guy now, vorewhore
    You'll be banned permanently sooner than later; in the mean time have the decency to stay out of other people's threads if you don't have anything sensible to say.

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Boosting differences
    By belsen in forum Lucene
    Replies: 0
    Last Post: 11-24-2010, 09:26 AM
  2. J2EE and J2ME differences
    By ianbram in forum Advanced Java
    Replies: 3
    Last Post: 11-27-2008, 09:19 AM
  3. Differences between constructor and method
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-19-2007, 08:53 AM
  4. differences: AWT and Swing
    By baltimore in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:01 AM
  5. differences between 2 dates
    By cecily in forum New To Java
    Replies: 1
    Last Post: 08-02-2007, 05:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •