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

  • Home
  • SEARCH
  • 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 627099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:29:30+00:00 2026-05-13T19:29:30+00:00

suggestBox.addKeyUpHandler( new KeyUpHandler() { public void onKeyUp(KeyUpEvent event) { if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {

  • 0
suggestBox.addKeyUpHandler( new KeyUpHandler() {
  public void onKeyUp(KeyUpEvent event) {
    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) { 
      String boxText = suggestBox.getText();
      if (!boxText.equals("")) {
        suggestPanel.add(checkBoxFactory(boxText, candidateNames));
        suggestBox.setText("");
      }
    }
  }
});

I haven’t been able to grasp why java forces me to declare the ArrayList (candiateNames) as final. Why is that?

  • 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-13T19:29:30+00:00Added an answer on May 13, 2026 at 7:29 pm

    It’s an inner class, passed into addKeyUpHandler — all variables referenced outside an inner class need to be declared as final to be used within the inner class. This is because the local class instance must maintain a separate copy of the variable, as it may out-live the function; so as not to have the confusion of two modifiable variables with the same name in the same scope, the variable is forced to be non-modifiable.

    Simply do final {type} {new-varname} = {old-varname}; before calling the method that uses the inner class, and then use {new-varname} inside that.

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

Sidebar

Related Questions

I am using SuggestBox to let user to select values. But however when there
Is there a widget for wxPython like the SuggestBox in Google Web Toolkit? It
Any suggestion on shortening following: $('#btn1').html($('#btn1').html().replace('string 1', 'string 22'));
Any suggestion how I can document my Perl code? What do you use and
After the suggestion to use a library for my ajax needs I am going
Does anyone have a suggestion for where to find archives or collections of everyday
I want your suggestion on the following pseudo-code. Please suggest how could I improve
I have followed the suggestion in this question... [ How to handle checkboxes in
Does anyone have a suggestion for creating paragraph-type line spaces within a <li> tag
I've previously encountered the suggestion to call System.Threading.Thread.Sleep(0); in tights loops in C# to

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.