Java Packages Default and Private Access Specifiers

In this tutorial, you will learn about java packages, default and public access specifiers.

You will learn what are java packages, how to create and use them, what is their advantages and then awhat are access specifiers, how to use default and public access specifiers, how do they work in detail with example.

Source code for this video tutorial

Code for Person.java

package oops;

class Person {
  String name;
 
  void introduce(){
  System.out.println("Hey i'm "+name);
 }
}

Code for Tutorial.java

package oops;

import fruits.*;

public class Tutorial {

 public static void main(String[] args) {
  
  Apple a = new Apple();
  a.color = "red";
  a.whichColor();
  
  Person anil = new Person();
  anil.name = "anil";
  anil.introduce();
  
 }

}
Back To Top