
How to compile a program using the package statement at the first line.Do I have to create a a Seperate Folder with the name of the package in my directory.Please tell me the steps?

Hi Friend,
Follow these steps:
1)Create folder named form in C:/Examples/ folder.
2)Create a java class Calculate inside the form folder:
package form;
public class Calculate
{
public int a;
public int b;
public int add(int a,int b){
return a+b;
}
}
3)Now to check this, create another class CallClass inside the Examples folder that will call the Calculate class.
public class CallClass{
public static void main(String[] args)
{
form.Calculate c=new form.Calculate();
System.out.println(c.add(5,6));
}
}
4)Compile the Calculate and CallClass class with the following statements:
C:\Examples\form>javac Calculate.java
C:\Examples>javac CallClass.java
C:\Examples>java CallClass
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.