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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:47:24+00:00 2026-06-10T13:47:24+00:00

I am interested why this fragment of code produces a syntax error saying ImmutableMap

  • 0

I am interested why this fragment of code produces a syntax error saying ImmutableMap cannot be resolved to a type:

ImmutableMap<String, String> advice = ImmutableMap<String, String>.builder()
                    .put(KEY1, VAL1)
                    .put(KEY2, VAL2)
                    .build();

While this code works as intended:

ImmutableMap<String, String> advice = ImmutableMap.<String, String>builder()
                    .put(KEY1, VAL1)
                    .put(KEY2, VAL2)
                    .build();

The period isn’t going where my mental model should and I was hoping someone could explain why the goes on the “method side” of the period. I’m using Guava’s ImmutableMap, but its not entirely relevant I don’t think. I think it has something to do with the generics but I’m not sure what and I’m not sure how to search to find a better answer since I don’t know what the concept would be called.

EDIT: For reference, ImmutableMap has this line for builder()

public static <K, V> Builder<K, V> builder() {
    return new Builder<K, V>();
}
  • 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-06-10T13:47:26+00:00Added an answer on June 10, 2026 at 1:47 pm

    builder() is a static method which has generic types associated with it, not the class it is defined in. It will be something like

    public static <K,V> ImmutableMap.Builder<K,V> builder() { ... }
    

    Note: the <K, V> here doesn’t have anything to do with the generic types of the class. (Which doesn’t have to be generic)

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

Sidebar

Related Questions

I am interested in doing this C code in Java: // sets n's ith
I'm currently using this code fragment to retrieve the one xml value that will
Apologies this is a very broad question. The code below is a fragment of
Today i have been interested in answers on this: where you create your work
I'm interested in how people use this feature: what domain, what relationships (apologies if
This is not homework . I am interested in setting up a simulation of
So this may seem like a widely-answered question, but I'm interested more in the
This is the query. Im mostly interested if there is a better way to
I'm interested in creating a plugin that does this simple task: Steps 1. User
I'm not interested in call or apply to change the this reference. Just for

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.