Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: cannot find symbol symbol: constructor ()

  1. #1

    Question cannot find symbol symbol: constructor ()

    i can't understand why show me this error please guide mee

    cannot find symbol
    symbol: constructor ()

    cannot infer type arguments for HashMap<K,V>
    reason: cannot use '<>' with anonymous inner classes
    where K,V are type-variables:
    K extends Object declared in class HashMap
    V extends Object declared in class HashMap

    static final Map<String, Color> COLOR_MAP = new HashMap<>() {
            {
                put("none", new Color(0, 0, 0, 255));
                put("blue", new Color(0, 0, 255, 255));
                put("green", new Color(0, 255, 0, 255));
                put("orange", new Color(255, 128, 0, 255));
                put("pink", new Color(255, 0, 128, 255));
                put("purple", new Color(255, 0, 255, 255));
                put("red", new Color(255, 0, 0, 255));
                put("white", new Color(255, 255, 255, 255));
                put("yellow", new Color(255, 255, 0, 255));
            }
        };
    Last edited by cnmeysam; April 6th, 2022 at 07:04 AM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: cannot find symbol symbol: constructor ()

    cannot infer type arguments for HashMap<K,V>
    reason: cannot use '<>' with anonymous inner classes
    Add the types inside the <> that the message refers to.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    cnmeysam (April 6th, 2022)

Similar Threads

  1. Cannot find symbol for constructor
    By tuctuc123 in forum Computer Support
    Replies: 1
    Last Post: October 14th, 2020, 11:38 AM
  2. Replies: 1
    Last Post: June 23rd, 2013, 02:37 AM
  3. [SOLVED] cannot find symbol
    By ATIBA SHEIKH in forum What's Wrong With My Code?
    Replies: 12
    Last Post: December 26th, 2012, 03:28 AM
  4. Cannot find symbol
    By BadgerWatch in forum What's Wrong With My Code?
    Replies: 4
    Last Post: November 6th, 2011, 11:25 PM
  5. Replies: 2
    Last Post: November 3rd, 2009, 06:28 AM