How to compile and execute a java program with package

write a program with package declaration

for example:

package mypack;

public class Example {
public static void main(String[] args) {
System.out.println("Hello World !!");
}
}

to compile above program type following command in command prompt

:\>javac -d . Example.java

to execute above program type following command in command prompt

:\>java mypack.Example


Comments

Popular posts from this blog

Number Pattern programs in java

String Related programs in java