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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:08:51+00:00 2026-06-11T22:08:51+00:00

I want to make my ArrayList with custom objects final so that the objects

  • 0

I want to make my ArrayList with custom objects final so that the objects cannot be changed after they are set.

I tried to declare it like this:

private final ArrayList<Datapoint> XML = new ArrayList<Datapoint>();

I fill the ArrayList with this lines:

FileInputStream fileIn = new FileInputStream(f);
ObjectInputStream in = new ObjectInputStream(fileIn);
XML = (ArrayList<Datapoint>) in.readObject();
in.close();
fileIn.close();

and this for-loop to show the objects:

for(int i=0;i<XML.size();i++){
                    item = XML.get(i);      
                    parsedData = parsedData + "----->\n";
                    parsedData = parsedData + "Name: " + item.getName() + "\n";
                    parsedData = parsedData + "stateBased: " + item.getStateBased() + "\n";
                    parsedData = parsedData + "mainNumber: " + item.getMainNumber() + "\n";
                    parsedData = parsedData + "dptID: "+ item.getDptID() + "\n";
                    parsedData = parsedData + "Groupadress: "+ item.getGroupadress() + "\n";
                    parsedData = parsedData + "priority: "+ item.getPriority() + "\n";
                }

xmlOutput.setText(parsedData);

But Eclipse says The final field XMLDetailsActivity.XML cannot be assigned.

What is the problem?

  • 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-11T22:08:52+00:00Added an answer on June 11, 2026 at 10:08 pm

    final keyword just mean that the reference to the object cannot be changed. It does not mean however that you cannot call the object’s method that changes its state.

    This can be achieved for list by using Collections.unmodifiableList().

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

Sidebar

Related Questions

< want to make a parcelable from an Object that contains an Arraylist, But
I want to make a Deep Copy of some Object[] and ArrayList How can
so i want to have an arraylist that stores a series of stock quotes.
I want to make my program print huge list of all files that I
I have to make a constructor for an ArrayList. So basically what I want
I want to make it so that a user clicks a button to launch
Hey I want to make a view appear below the last that has been
I am making an application in which i want to make sure that only
I want to make a custom RelativeLayout, but I keep getting this error: 08-01
I have a problem when I want to make custom listview in android. MyListView

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.