Implement the print method

  • 3
  • Locked
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 (113)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Doomer man
Level 3 , United States of America
7 June, 23:38
I got the answer but I don't know why the argument (String s) works the way it does, where in this code do we even declare string s and why does string s print everything from the main method, how and why does it store all 3 prints and could you pass on a different argument like String A or something and would it store all those print statements the same way? I guess what I am trying to say here is that why does the argument String s works the way it does where it prints all 3 statements instead of like 1 statement?
Anonymous #10991784
Level 2 , Tamilnadu , India
4 May, 06:32
why not print👇 Java is easy to learn! Java is object-oriented! Java is platform-independent! Java is easy to learn! Java is object-oriented! Java is platform-independent! Java is easy to learn! Java is object-oriented! Java is platform-independent! Java is easy to learn! Java is object-oriented! Java is platform-independent! why print👇 Java is easy to learn! Java is easy to learn! Java is easy to learn! Java is easy to learn! Java is object-oriented! Java is object-oriented! Java is object-oriented! Java is object-oriented! Java is platform-independent! Java is platform-independent! Java is platform-independent! Java is platform-independent!
Jeff Kenney
Level 3 , United States
28 November 2021, 05:01
After reading all of these comments, it appears that the CodeGym Team could add some extra explanation here. The exercise seemed a little poorly timed as I was only able to figure out the solution from reading the comments here. However, the easiest fix for the confusion here would be adding an extra sentence in the instructions mentioning how the program calls the Main String through String S or something like that. That is just my opinion 🤷‍♂️.
vishal sharma Java Developer
14 October 2021, 19:02
System.out.println(s); four time but i dont know why is right
Dav
Level 2 , United States of America
23 October 2021, 13:35
Bc “System.out.println(s);” is in the method print not main. -using println puts it on a new line -the method main calls print the correct number of times
Anonymous #10829459
Level 2 , Spain
6 October 2021, 19:23
no es sencillo me pase 31 veces haciendolo, es repetir el system.... x 4 y ya sta. aunque dice que no se puede poner pero que va, esto esta loco.
Anonymous #10930828
Level 2 , Spain
20 February, 18:48
Hola, como lo resolviste, no me queda claro como mandar a imprimir sin utilizar System.out..... Gracias
jonathan fonseca clavijo
Level 10 , Colombia
17 March, 02:29
¡Amigo, aquí te dejo un par de pistas 1. input print("Java is easy to learn!"); print("Java is object-oriented!"); print("Java is platform-independent!"); 2 output Java is easy to learn! Java is easy to learn! Java is easy to learn! Java is easy to learn! Java is object-oriented! Java is object-oriented! Java is object-oriented! Java is object-oriented! Java is platform-independent! Java is platform-independent! Java is platform-independent! Java is platform-independent! Lo que debes hacer es completar el metodo print para que imprima un texto s ingresado por parametro 4 veces
Víctor Alfonso Martínez Gómez
Level 3 , Manizales, Colombia
30 July 2021, 17:58
El enunciado esta muy confuso
MathBechy
Level 2
2 July 2021, 05:18
I don´t understand that 😔
4 July 2021, 06:14
print is the name of the method. the next in green colour inside the brackets are the value that is passed to the method. Downwards, the "public static void print" is the method itself. Inside the brackets it's declared the type of variable that it will receive from the main class, in this case a String, and also the name that this string will have inside the method, in this case s. Given this, I think is clear what you need to print a String 4 times.
mahdi mahdi
Level 2 , Jeddah, Saudi Arabia
15 June 2021, 14:19
i dont understand what want me do
mahdi mahdi
Level 2 , Jeddah, Saudi Arabia
15 June 2021, 14:25
in frist say print then say shod not us print and printlin
James Hensley
Level 2 , Chicago, United States
29 May 2021, 02:10
hint; guess, and then see if you're right. another hint, you must call the lines from the first module within the method.
NaTasia Madison
Level 8 , Atlanta, United States
15 May 2021, 02:19
This was a little challenging at first but I figured it out. Are there other solutions other than the for loop?
Dav
Level 2 , United States of America
23 October 2021, 13:37
While loops, do while loops, and straight forward “println” the correct number of times.