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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:15:58+00:00 2026-05-11T05:15:58+00:00

DUPE: Private vs. Public members in practice (how important is encapsulation?) In the course

  • 0

DUPE: Private vs. Public members in practice (how important is encapsulation?)

In the course of writing a program in Java, I have abstracted out some libraries that I can see a possible use for in future projects.

Why should I bother with setting restricted access (private/protected) on any of these methods?

It seems like this will just make my life more complicated in the future. If I use public on everything, I will never need to worry about whether I can call something from some other class. I have never seen a case in any of my code yet where it made any sense for me to use anything except public.

Is it so wrong to use ‘public’ on everything? Am I going to be struck down by the Java gods?

  • 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. 2026-05-11T05:15:58+00:00Added an answer on May 11, 2026 at 5:15 am

    Yes, it’s wrong to use public on everything. It means you have absolutely no concept of the difference between ‘this member is part of a public API; you’re expected to be able to use it from the outside world, and it shouldn’t change’ and ‘this member is an implementation detail. If I want to change it later, I can do so because I know nothing from the outside world will be calling it.’

    Having a clear split between API and implementation is important for flexibility and clarity IMO.

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

Sidebar

Related Questions

This is not a dupe of Calling a method with ref or out parameters
i have a list of lists that looks like this: dupe = [['95d1543adea47e88923c3d4ad56e9f65c2b40c76', 'ron\\c',
I'm working on some code to insert a link to a dupe in the
Update : this is more-or-less a dupe , and it turns out to be
I have a web service I'm calling that does a dupe check based on
I hope this is not a dupe - I have searched long and hard
Dupe of calculate playing time of a .mp3 file im reading a audio file(for
Dupe: return statement in a lock procedure: inside or outside The title is a
Sorry if this is a dupe. There are many similar questions but it seems
Hope this is not a dupe. I would like to be able to do

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.