# Addition and multiplication Program using the user-defined package

- Link: https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/
- Published: 2018-11-07T14:31:20+05:30
- Author: Ashishkumar Vishwakarma

In this article, we see Addition and multiplication Program using the user-defined
package

Java package is a mechanism of grouping similar types of classes, interfaces, and
sub-classes collectively based on functionality. When software is written in the
Java programming language, it can be composed of hundreds or even thousands of individual
classes. It makes sense to keep things organized by placing related classes and 
interfaces into packages.

## Program to create a user-defined package

Addition and multiplication Program using user-defined

##### Source code

    ```language-dotnet
    //CREATE A NEW FILE NAME AS A1
    package A1; 
    public class A// DEFINE IN PACKAGE A1
    {
    	public void add(int x,int y)
    	{ 
    	int z=x+y;
    	System.out.println("Addition"+z);
    	}
    }//END OF CLASS

    //CREATE A NEW FILE NAME AS A2
    package A2; 
    public class B //DEFINE IN PACKAGE A2 
    {
    	public void mul(int x,int y) 
    	{
    	int z=x+y;
    	System.out.println("Multiplication"+z);
    	}
    }//END OF CLASS

    //CREATE A NEW FILE NAME AS pack
    import A1.A; 
    import A2.B; 
    public class pack 
    {
    	public static void main(String args[]) 
    	{
    		A a-new A(); //OBJECT OF CLASS A 
    		B b:new(); // OBJECT OF CLASS B 
    		a.add(10,20);
    		b.mul(10,20)
    	}//END OF MAIN 
    }//END OF CLASS 
    ```

Also, you can use the Java [compiler](https://www.onlinegdb.com/online_java_compiler)
to compile a program.

### Output.

> C: \A>javac -d . A.java 
> C: \A>javac -d . B.java C: \A>javac pack.java C:\A>java
> pack Addition=30Multiplication=200

Also, View:[ – Write a program to create a registration form using AWT](https://technotaught.com/registration-form/).

Also, View- [Write a java program to create a window using swing.](https://technotaught.com/22-write-a-java-program-to-create-a-window-using-swing/)

### Share this:

 * [  X ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=twitter)
 * [  Facebook ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=facebook)
 * [More](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/#)

 * [  WhatsApp ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=jetpack-whatsapp)
 * [  LinkedIn ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=linkedin)
 * [  Email ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?subject=%5BShared%20Post%5D%20Addition%20and%20multiplication%20Program%20using%20the%20user-defined%20package&body=https%3A%2F%2Ftechnotaught.com%2Faddition-and-multiplication-program-using-the-user-defined-package%2F&share=email)
 * [  Reddit ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=reddit)
 * [  Tumblr ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=tumblr)
 * [  Pinterest ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=pinterest)
 * [  Telegram ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/?share=telegram)
 * [  Print ](https://technotaught.com/addition-and-multiplication-program-using-the-user-defined-package/#print?share=print)

### _Related_
