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 6168525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:42:12+00:00 2026-05-23T22:42:12+00:00

I rather like the diamond syntax for generics that Java 7 introduces – not

  • 0

I rather like the diamond syntax for generics that Java 7 introduces – not so much from a time saving perspective (after all most IDEs fill that bit in for you anyway) but just because it makes the code look a bit cleaner. Because of this and other reasons (mainly the fact I’m developing a new piece of software and some of the new APIs in Java 7 will be useful) I’m most likely going to switch the existing codebase to use / require Java 7.

However there’s a fair chunk already written pre-diamond syntax, and I’d like to consistently use the diamond syntax throughout. Is there an IDE shortcut (I’m using Netbeans but obviously can open the project in any free IDE to do the task) or something else that can automatically switch the existing generic code to use diamond syntax?

  • 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-23T22:42:14+00:00Added an answer on May 23, 2026 at 10:42 pm

    Oh yes, I have successfully done this on IntelliJ (free Community Edition).

    Menu > Analyze > Inspect Code…

    In the result, select “Java language level migration aids > Explicity type can be replaced with <>”

    Right click, run “Apply Fix ‘Replace with <>'” And you got diamonds.

    There was a bug about diamond on anomymous classes, so some code may not compile after the fix. You’ll have to revert them back then.

    // anonymous class, <> doesn't work.
    new Factory<Pig>(){ ... }  
    // however IntelliJ may wrongly "fix" it to
    new Factory<>(){ ... }   // does not compile.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've often heard Ruby's inject method criticized as being slow. As I rather like
Why do most C programmers name variables like this: int *myVariable; rather than like
Rather than reinvent the wheel I would like to use Outlook to manage my
I would like to ask a rather, general, high-level introductory kind of question regarding
For a rather obscure use case I'd like to have a (large) statically linked
I would like to display a catergory page as my homepage rather than a
I would like to create my ObjectDataProvider in my C# code behind rather than
I have a rather large diff of 2 GIT branches and would like to
Rather than doing my_var = my_var+'extra string'; is there a shorthand method like .=
I'd like to view historical data for guest cpu/memory/IO usage, rather than just current

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.