Welcome to Java Examples

Take a cup of tea and Let's Start programming



create folder and gave it your package name...

package jaimin; /** * * @author Jaimin Shah */ public class package_example { //create your own method... 
//note:- make all method public..
//here i'm creating the method to show package created.. public void show() { System.out.println("Package created"); } //save this file in your package folder and compile this file }





now create second file in which you want to use your package

import jaimin.package_example; /** * * @author Jaimin Shah */ class package_demo extends package_example { public static void main(String [] args) { //create object of package_example class package_example j = new package_example(); //call method j.show(); } }
output
package created

0 comments :

Post a Comment