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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:32:35+00:00 2026-06-13T01:32:35+00:00

I have done a lot of searching for what this compiler error <identifier> expected

  • 0

I have done a lot of searching for what this compiler error <identifier> expected means, and none of them seem to apply to my situation. Really sorry if this is a duplicate or basic info, but I can’t find anything anywhere.

The following code works fine. Note that I am positive myObject1 is indeed a HashSet<String> so the cast is ok.

@SuppressWarnings("unchecked")
HashSet<String> s1 = (HashSet<String>) myObject1;

The following code does NOT work fine. It will compile, but with warnings.

@SuppressWarnings("unchecked")
HashSet<String> s1;
s1 = (HashSet<String>) myObject1;

So then I try the code below.

@SuppressWarnings("unchecked")
HashSet<String> s1;
@SuppressWarnings("unchecked")
s1 = (HashSet<String>) myObject1;

Now it refuses to even compile, giving me the <identifier> expected error that is puzzling me so much. The ^ symbol in my command line is pointing right before the = in the last line. I’m not sure what on earth I could be expected to put BETWEEN the s1 and the =.

Any ideas? Thanks!

  • 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-13T01:32:36+00:00Added an answer on June 13, 2026 at 1:32 am

    You can’t apply an annotation to a simple assignment statement. From section 9.7 of the JLS:

    Annotations may be used as modifiers in any declaration, whether package (§7.4.1), class (§8.1.1) (including enums (§8.9)), interface (§9.1.1) (including annotation types (§9.6)), field (§8.3.1, §9.3), method (§8.4.3, §9.4), formal parameter (§8.4.1), constructor (§8.8.3), or local variable (§14.4.1).

    I agree that the compiler error message could be rather clearer, admittedly…

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

Sidebar

Related Questions

I have done a lot of searching on this topic but still couldn't get
I've done a lot of searching and there seem to be similar issues, but
I've done a lot of searching trying to figure this out: I am soon
I've done a lot of searching on this, so please forgive me if I've
I've done a lot of searching and not found anything like this, but I
So i've done a lot of searching on here and Google and haven't seem
I have done a lot of searching to what appears to be a simple
I have done a lot of searching to find a way to start a
I am new to LINQ to SQL, but have done a lot of database
I have a process that uses an XmlReader. I have already done a lot

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.