0

what method please give me some examples thanks.

19th Aug 2016, 9:04 PM
johny
2 Antworten
+ 2
I assume your question is "What is a method?"... If so, think about it as a verb in your program. They are the blocks of code that will perform actions in your code. Some examples are things you do in real life: Sum(), Divide(), Walk(), Snore(), Drink(). See? They are all verbs... Now, lets get more technical. Lets implement the method Sum(). This is the syntax to follow when creating a Verb/Method/Function/Sub-Routine, etc: ignore the + return type + name + ( ) { //Here is where you code the action of the method... } ok, so our method will return an integer, i want the sum of 2 numbers to return to me a variable called result of type integer. The two numbers are called parameters and you have to declare them inside the parenthesis. Lets code: int Sum(int num1, int num2) { int result = num1 + num2; } That was the implementation of the method Sum(). I hope you learned the basics of methods. Ask if you dont understand anything else. Happy coding!
20th Aug 2016, 6:37 PM
Pablo Hernandez
0
thanks so much.
21st Aug 2016, 12:48 PM
johny