Results 1 to 3 of 3
  1. #1
    R03
    R03 is offline Member
    Join Date
    Apr 2014
    Posts
    10
    Rep Power
    0

    Default modifier [public|default|private|protected] ?

    Hi, Me Again..
    sorry.. I'm confused to explain this, and to make a good subject..
    what exactly happen, when i type the code (class) without public ? it mean my class cannot acces by public ? then what really happen if i modified the modifier [public|default|private|protected] ?

    if the normal code could be like this

    Java Code:
    public class Program_1 {
    	public static void main (String[] programs){
    		System.out.println("Hello world");
    	}
    
    }
    then i modified like this ?

    Java Code:
    [default or private or protected] class Program_1 { //choose one : default, private, or protected
    	[default or private or protected] static void main (String[] programs){ //choose one : default, private, or protected
    		System.out.println("Hello world");
    	}
    
    }

    what really happened ?

    thank you
    R03.

  2. #2
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: modifier [public|default|private|protected] ?

    You're referring to access modifiers, which are better explained by tutorials. Here're a couple:

    (Internet search term: "java access modifier")

    It is good programming practice to use the narrowest possible access modifier.

  3. #3
    R03
    R03 is offline Member
    Join Date
    Apr 2014
    Posts
    10
    Rep Power
    0

    Default Re: modifier [public|default|private|protected] ?

    Quote Originally Posted by jashburn View Post
    You're referring to access modifiers, which are better explained by tutorials. Here're a couple:

    (Internet search term: "java access modifier")

    It is good programming practice to use the narrowest possible access modifier.
    Hi Jasburn,

    Thank you so much for reference..

    Regards,
    R03.

Similar Threads

  1. Replies: 1
    Last Post: 02-10-2011, 05:43 AM
  2. Protected access modifier in Java
    By bluepratz in forum New To Java
    Replies: 6
    Last Post: 08-04-2010, 11:08 AM
  3. protected modifier ? Constructors
    By javanew in forum New To Java
    Replies: 6
    Last Post: 04-06-2010, 12:59 PM
  4. Regarding default access modifier?
    By makpandian in forum New To Java
    Replies: 2
    Last Post: 03-14-2009, 09:21 AM
  5. why we use public access modifier?
    By vichet in forum New To Java
    Replies: 1
    Last Post: 04-04-2008, 08:04 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •