Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:52:41+00:00 2026-05-30T18:52:41+00:00

I watched the Oracle OTN Virtual Event: Java SE and JavaFX 2.0 (28 Feb

  • 0

I watched the Oracle OTN Virtual Event: Java SE and JavaFX 2.0 (28 Feb 2012) and while talking about the new diamond operator (that Map<String, List<String>> myMap = new HashMap<>(); thing) the speaker mentioned that it was not as simpleto implement than one might think, as it is not a simple token replacement.

My question is why? Why can’t be this implemented as simply taking the string from the variable’s declaration and put it into the diamond operator?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:52:42+00:00Added an answer on May 30, 2026 at 6:52 pm

    I didn’t implement it either, so I can only guess.

    But usually the reason these things are more complex than they seem is that first inspection only looks at the most common (or most publicized) use case. In this case it’s the one you mentioned. In theory that should be easy to specify exactly and it should be rather easy to implement in a compiler.

    However, the diamond operator (which is not technically a operator, by the way) can be used in different ways as well:

    someMethodWithGenericArguments(new HashMap<>());
    new SomeGenericClass(new HashMap<>());
    T foo = new SomethingRelatedToT<>(); // where T is a generic type parameter
    

    In those cases a simple token replacement obviously no longer works, you need actual type inference involving real type analysis (i.e. it’s on an entirely different abstraction level as a simple token replacement would be).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just watched a session of PDC09 about new features of Entity framework in
I watched the Stanford online video lecture about java programming by Mehran Sami. In
I watched few videos/webcasts about Oslo but I still fail to see how it
I watched today as someone painlessly exported a NetBeans java project to a JNLP
I just watched a video of Douglas Crockford's presentation about his 2009 book JavaScript:
I watched video tutorial about pagination in PHP. Author used 4th version of PHP
I have recently watched a video of Nicholas Zakas talk about high performace scripts.
I've watched the WWDC 2010 talks about adopting multitasking and I have started enabling
I watched my lecturer's video from my university and he says about the Rational
I have just watched the bug report https://bugs.java.com/bugdatabase/view_bug?bug_id=6972329 so I want to ask... Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.