BR: WAP for the addition of two numbers
public class Addition_Program {
int number_One=45;
int number_Two=47;
number_One + number_Two =====> whenever we add these two numbers we will get 97
Here 97 is also data that should be placed inside a container called a variable.
We need to declare a new variable to place that value
97 is of type integer
}
----------------------------------------------------------------------
public class Addition_Program {
/* These two lines are like ingrediants
int number_One=45;
int number_Two=47;
/* business logic/ implementation
int result = number_One + number_Two
}
Now compile and execute
>>> javac Addition_Program.java
But this business logic/implementation of a business requirement should not be a normal statement that should be under inside one more container called Methods.
Methods:
If we want to write business logic/ business implementation it should be there inside a container called method.
A class contains variables and methods
There are two types of methods:
1. Static methods
2. Non-static methods
No comments:
Post a Comment