HOW DO I DO THIS TASK
HOW DO I FINISH THIS TASK
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Ahmad Dabagh
16 September 2020, 10:48
As a Hint You have to use ( for Loop )
0
Anthony Chalk
16 September 2020, 11:28
There's no need to use one
0
Anthony Chalk
16 September 2020, 10:32useful
Let's understand first what a method is:
A method is simply a block of code that runs when it is called.
- a block is any code that is written between { and }
- you call a method by writing it's name (in this task the method name is "print" and it is called 3 times in the main method.
Let's break down the method in question:
- public: this an access modifier, you don't need to know about this yet
- static: another type of modifier, ignore for the moment
- void: this is the return value of the method. This method does something but doesn't return a value - hence void
- print: this is the method name
- (String s): this means that whenever you call this method, in the brackets you have to write a String. This could be any String as you can see in the main method. This is called passing an argument to a method.
If in the method body (between the { and the }) you write some code that does something with "s", whenever you call the method and write a String in the brackets, the exact same code will be executed on that String.
All this being said, you need to display whatever String is passed as an argument to the method whenever it is called. Hopefully you can work it out from here. +2