1.First Code (Main Class)
2.Second Code (Place where there are a lot of methods)
Next, I want you guys to run this program, Input what it asked and then Press 'Enter'. Remember guys, whenever you are using more than one class, Run your codes from the main class. In this case, my main class named "maain". This is an example of program that combine your answer with a string from another methods by using more methods. Let me explain to you each line of these codes.
First Program :
Line 1
"Import java.util.Scanner;" is a keyword for you to tell Java that you need to use the scanner utility. So, whenever you want to input some stuff in your program when it runs, you will have to import the java scanner's utility by typing "Import java.util.Scanner;" in your program.
Line 2-3
The declaration of your main class and the method inside it.
Line 5
The code on the picture above is the declaration of variable "input" as a place where your Input stored. System.in shows that whatever you type on your keyboard to input data, the data that you input will be stored in the "input" variable.
Line 6
"NameOfClass (space) NameOfClassObject = new (space)NameOfClass( );"
Line 8-9
Line 8 print out a text that told you to enter the a name(a String), then Line 9 determine where is your input will be stored.
Line 11
It means that you want to use another class named "message" in the "change" methods by using the value of variable "name".
Line 12
It means that you want to use another class named "message" in the "text" methods.
Second Program :
Line 2
The declaration of your class.
Line 3
Declaration of a new variable named "getname". In this case, private means that this variable can only be used in this class, it can't be used by another class
Line 4
Declaration of a method called "change" which excecuted by using the value of variable "name".You can declared a new variable inside the parameter.
Line 6
This declared that the value of "name" is equal "getname".
Line 9
Declaration of a new variable named "backname".
Line 11
It means that the value of "backname" variable is returned to the "getname". Which make both of the variables have the same value.
Line 14
Declaration of a method called "text".
Line 16-17
These are the what Java will do if you use/run "text" methods.Because these two lines are inside the curly brackets of "text" method.
So that's it guys for now. Thank you guys for visiting my blog, hope you guys enjoy it and see you on the next tutorial. If you guys got something to be asked, please leave a comment below and thank you very much.
Greetings from Programmer !
No comments:
Post a Comment