Develop a program which consists of the package named let_me_calculate with a class name Calculator and a method name add to add two integer numbers. Import let_me_calculate package in another program (class name Demo) to add two number.
Code:
package let_me_calculate;
public class Calculator
{
public void add()
{
int a=20;
int b=30;
int c;
c=a+b;
System.out.println("Addition = "+c);
}
}
import let_me_calculate.*;
class Demo
{
public static void
main(String args[])
{
Calculator obj=new
Calculator();
obj.add();
}
}
Output:
Comments
Post a Comment