Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Why are we so concerned with things like public, private, etc. in Java?

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why are we so concerned with things like public, private, etc. in Java?

    If it weren't obvious by my asking of this question, I come from Python.

    Anyways, I am wondering what all the nonsense is about declaring things to be abstract, private etc. for "security". The program is entirely at our fingertips, and we control what happens. If we don't want a class to access another class, then how about we just don't do it in the first place? Are we worried about hackers, or that we will somehow sleepwalk over to our computers and violate access modifiers in our sleep? I just don't get why we are trying to protect ourselves from ourselves.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Why are we so concerned with things like public, private, etc. in Java?

    Have you heard of the expression> Shoot yourself in the foot.
    Making a method private is a way to prevent someone from shooting themselves.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Changing from Public to private
    By Peacetoyou in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 24th, 2019, 06:04 PM
  2. Need understanding for public and private.
    By pratik5317 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 25th, 2013, 06:28 AM
  3. Chatting application in java (PUblic And private)
    By nakul dev in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 27th, 2012, 12:27 PM
  4. Convert string to private and public key
    By Ganezan in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: January 5th, 2010, 08:37 AM
  5. Private or public variables??
    By igniteflow in forum Java Theory & Questions
    Replies: 2
    Last Post: September 17th, 2009, 08:07 AM