Last active
August 29, 2015 14:04
-
-
Save kenorb/f402fd9b6e590b213df6 to your computer and use it in GitHub Desktop.
Student.java - Package Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Student.java - Package Demo | |
* | |
* - A package acts as a container which holds .class files. | |
* - Packages avoid the namespace collisions between the classes. | |
* - Once a package is created, it can be re-used or imported to any source code. | |
* - A package can be created using a package statement: package package_name. | |
* | |
* Usage: | |
* javac -d . Student.java | |
* | |
* It creates a directory structure (p1-->p2-->p3). | |
*/ | |
package p1.p2.p3; | |
public class Student { | |
private int id; | |
private String name; | |
private String course; | |
public Student() { | |
id = 1000; | |
name = "Krish"; | |
course = "OCP"; | |
} | |
public void getStudent() { | |
System.out.println(id + " " + name + " " + course); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment