Click here to watch in Youtube :
https://www.youtube.com/watch?v=SotFxl07eAM&list=UUhwKlOVR041tngjerWxVccw
Student.java
StudentDemoTest.java
https://www.youtube.com/watch?v=SotFxl07eAM&list=UUhwKlOVR041tngjerWxVccw
Student.java
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(); student.name = "Dave"; student.age = 23; } }
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The field Student.age is not visible at StudentDemoTest.main(StudentDemoTest.java:8)
https://sites.google.com/site/javaee4321/java/AccessModifiersDemoPrivate-PublicApp.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/AccessModifiersDemoPrivate-PublicApp
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/2f20a20e875ab6e7de15adc0041c373263d61c3b/BasicJava/AccessModifiersDemoPrivate-PublicApp/?at=master
See also:
No comments:
Post a Comment