array in a java class

i read like wrapping array in class protects array from being inadvertently altered. i have not understood what it means. Can you please advise with some sample code, link, resource.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dung TrinhMarching Band Field CrewCommented:
Do you mean setting it as a private variable?
Dung TrinhMarching Band Field CrewCommented:
I think this is what that sentence mean

public class Myclass 
      private int[] myArray = new int[60];

Open in new window

Now no one can mess with your array. Only the function in Myclass can change the data in myArray

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zzynxSr. Software engineerCommented:
I think Dung is right.
If you do it like that, everyone using your Myclass can't change the internal/private int array. They don't even know it exists.
The only thing they can do is calling the public methods of Myclass to manipulate the data in it.
So as the developer of Myclass you (and only you) decide how you fill up and read from that array and nobody from "outside" can tamper with the data inside the Myclass.
Also, if later on you decide to replace the array with something else (e.g. a list), nobody "outside" should know or even care about that, as long as you keep the same methods (e.g. to add and get data values) your class keeps working as a user expects it to work.
Tomas Helgi JohannssonCommented:

You can define the array variable as public, private or protected depending on which access level method you would like it to have in your coding design.
Look at these

    Tomas Helgi
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.