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: Default Access (package access) confusion

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Default Access (package access) confusion

    Hi eveybody,

    I am new to java and as I was reading, I came accross the default access modifier i.e. package level access modifier which is used to restrict only the classes in the same package to access the class.

    I've understood the concept and how it is applied technically but I am not able to figure out in which situations package level access would fit in. Can someone help me giving a short scenario or a practical example where package level access can be used.

    thanks


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Default Access (package access) confusion

    Hello, I've been working as a Java Developer for a number of years now and I can tell you I've never used the package level (default access modifier) on purpose at any time.....yet.

    The purpose of this modifier is of course if you have a case where you want to have support classes which are not static inner classes but you would like these to be protected and only used by one or several main classes in your package.

    // Json

Similar Threads

  1. How can i store ArrayList objects in Access database
    By frankycool in forum JDBC & Databases
    Replies: 0
    Last Post: November 4th, 2009, 12:44 AM
  2. Access the Same Socket
    By ahmmnhwa in forum Java Networking
    Replies: 5
    Last Post: October 29th, 2009, 11:50 AM
  3. access database connectivity from outside an application
    By suchirag in forum JDBC & Databases
    Replies: 0
    Last Post: October 29th, 2009, 02:03 AM
  4. Random Access File
    By silver_unicorn in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: August 12th, 2009, 01:51 AM
  5. Random Access File
    By silver_unicorn in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: August 10th, 2009, 10:44 PM