Implement the print method

  • 3
  • unavailable
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.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
AdityaLevel 2 , Baleshwar
yesterday, 12:20
I did it with simple use of for loop
yehuda bLevel 6 , Beersheba
13 November, 15:39
Why is the output 4x "Java is easy to learn!" and then 4x "Java opens many opportunities!" and not 1x "Java is easy to learn" and then 1x "Java opens many Opportunities!" repeated 3x ?? After writing above question I realized that @naboo78 answered this, in the parenthesis of his/her comment (basically that the the print method is defined (to print 4x string s), then called in the main method twice, @ the first time being called the method parameters are defined as Java is easy to learn! so the program outputs that 4x, whereas the second time it's called the parameters are defined as Java opens many Opportunities! thus outputting that 4x!) many lessons to learn from 1 task! Thanx @naboo78!
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 ???
CodemonsterLevel 4 , Dubai
2 December, 07:56
hi John . System.out.println() prints something on the screen .just like how System.out.println("hello world"); prints hello world . System.out.println(s) prints the value stored in string S .If you are confused why we don't write System.out.println(String s); it is because in the function definition ie 1) your saying this function accepts a String s and it prints the string. moreover you don't declare System.out.println(String s) in programming 1) public static void print(String s) { System.out.println(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
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 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!