Wednesday, 25 November 2015

Java Tutorial : Java Access modifiers private and public

Click here to watch in Youtube :
public class Student
     * public modifier — the field is accessible from all classes.
    public String name;
     * private modifier—the field is accessible only within its own class.
    private int age;

public class StudentDemoTest

    public static void main(String[] args)
        Student student = new Student(); = "Dave";
        student.age = 23;

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
    The field Student.age is not visible

    at StudentDemoTest.main(
Click the below link to download the code:

Github Link:

Bitbucket Link:

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge