Teacher elly

Implement the print method

  • 2
  • Locked
  • Exercise
Writing your own methods is the way to achieve unlimited freedom, but it is also a great responsibility. We implement methods carefully and thoughtfully. This task requires you to write a print method that will display a certain string. Not once, but four times. The string is a method argument, meaning that it will be supplied as an input.
You can't complete this task, because you're not signed in.
Comments (51)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
SanthiyaLevel 2 , Holalkere
25 July, 15:05
i done really simple
PratyakshLevel 2 , Houston
22 August, 00:40
help me pls...
ReginaLevel 41
22 August, 15:48
In case you face difficulties with the task, please refer to the section Help at our website.
PratyakshLevel 2 , Houston
12 September, 18:23
Thank you Regina..
John LeoLevel 5 , Shenzhen
22 July, 09:30
System.out.println(s) is Ok,but i don't know why it is the right answer
anytaraliLevel 2
6 September, 01:41
Hello John, did you figure it out ???
FRANCIS MENEZESLevel 2 , Manor
26 June, 17:27
public static void main(String[] args) { print("Java is easy to learn!"); print("Java opens many opportunities!"); } How is above portion related to this ( public static void print(String s) )
Akash ShekhavatLevel 2 , Nagpur
24 June, 04:33
I tried it but code is not runnig please help
RomanLevel 41
24 June, 06:02
If you need help, something isn't right in your code, the server won't accept your solution (even if you are 100% sure that it is correct). Describe your question/issue in the HELP section at codegym.cc/help.
galinaLevel 7 , Montreal
19 June, 04:48
I used "for" loop.
Umar farooqLevel 2 , Daultala
15 June, 17:36
Just write System.out.printIn(s); (4 times) under the print method and see results.
YuanLevel 3 , Beijing
16 June, 07:29
For loop, you can find it in level 1,lesson 1.
John LeoLevel 5 , Shenzhen
22 July, 09:32
Why s equals the sentence?
akshat shrivastavaLevel 2 , Pune
13 June, 14:22
can anyone explain this.?What we need to do here and how to do it.? I am not able to understand a bit of it..!
piyushLevel 2 , Delhi
2 June, 10:51
why string s is used here ?
shiv alphLevel 3 , New York City
2 June, 17:17
String s is a method parameter. It is the variable that is declared inside the print method and only can be used inside that method. String s cannot be used outside the print method. When we use the print method inside the main method the String that is entered is used as String s variable inside of the print method. print(parameter) I recommend reading up on https://www.geeksforgeeks.org/methods-in-java/ It is a great resource for learning programming Code below makes String s = "Java is easy to learn!" The type is specified as String and s is the variable name, The type and name can be whatever you decide to use.
print("Java is easy to learn!");
In the code below I can only use the String s inside that method so I choose to append the String yes to the String s
public static void print(String s) {
    //write your code here
        s += "yes";
}
Rajendra KLevel 2 , Stockholm
14 May, 08:42
The output expected is below: Java is easy to learn! Java is easy to learn! Java is easy to learn! Java is easy to learn! Java opens many opportunities! Java opens many opportunities! Java opens many opportunities! Java opens many opportunities!
Mike ThomasLevel 2 , Bozeman
1 May, 18:11
I solve this but I'm not sure where the string is defined. I used System.out.println(s); This worked but where is the print("Java is....")and print("Java opens.....") assigned the string variable"s". Is this in the line "public static void print(String s) ???