Implementing Package in Java
What is a package?
- A package is a namespace concept which organizes a set of related interfaces and classes.
- It can be thought of as different folders on your system.
Implementing Package
package com.pratikkataria.java; public class Main { public static void main( String[] args) { System.out.println(args[0]); } }
- This Main.java file needs to be kept inside folders:
- com -> pratikkataria -> java -> Main.java
- So the command prompt needs to be started in the location where the com folder is:
- K:\>
- CONSOLE:
- K:\>javac com\pratikkataria\java\Main.java
- K:\>java com.pratikkataria.java.Main MyArg
- OUTPUT:
- MyArg