Inside the main, until now we only do programs that only have one class(file), I am using the example before, so sout-Hello is there because don't prejudice and don't make nothing.
So I have to make that declarations, I am using only integer numbers, have the ones that have fraction.
so I want an operation with two numbers, in my example I am putting the number inside variables that are int - because in the next example I gonna use that to make a program that will ask the numbers for the user to the sum and I will put that values inside var. I put numbers in variables because in the future we gonna designe a better program, the Java know sum 4 plus 3.
So in Java we have to declare the variable by his type (int) and gave a name to storage the value.
so we have to type:
int x = 3;int y = 4;
Inside the main right inside its brackets{}, just like the picture above;
After we gonna type(the variable where we gonna storage the sum):
int sum = x + y;
what means those lines, >>int<< is the part of the declaration that say that the variable by his type
x, y, sum is the name of the variable and = is to say that variable gona receive that value, the value is what is at the right of the = . And to the Java show the result we gona use the sout, and ask in the middle of the parenthesys the sum, why sum isn't with "" quotations, because sum is now an variable and not String, the computer don't understand what yuo talk but he understand methods, classifications and sum is now for the computer the act of sum what is stored inside x and y.
Congrats Rute you used an IDE to sum, can we dream in bolder flies, we have exceeded the bounds of safety, we came out of the floor with 1 ton of smartness and cross the skies like a jet plane. Rute Bezerra de Menezes Gondim
No comments:
Post a Comment