Implement the print method

  • 3
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 (93)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
mahdi mahdi
Level 2 , Jeddah, Saudi Arabia
about 5 hours ago
i dont understand what want me do
mahdi mahdi
Level 2 , Jeddah, Saudi Arabia
about 5 hours ago
in frist say print then say shod not us print and printlin
James Hensley
Level 2 , Chicago, United States
29 May, 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 4 , Atlanta, United States
15 May, 02:19
This was a little challenging at first but I figured it out. Are there other solutions other than the for loop?
John Hanagan
Level 2 , Newark, United States
29 April, 05:51
Bs, i got premium, it even shows the expiration date and yet I cant use hint...
Pahunchik
Level 7 , Moscow, Russian Federation
2 March, 19:42
I did it, but i did not understand how((( I dont understand what means "(String[] args)" and i know nothing about print comand. Why this task is here already?It's depressing when a task is given without a prior theory
John Squirrels Website Admin at CodeGym
4 March, 10:13
The theory will be explained later on to you. It is most def a task from the future.
sampex03
Level 4 , Berlin, Germany
5 February, 20:35
I am baffled that I still end up with a wrong feedback even when I do what I learned to implement the solution. Help me, someone...
Forrest
Level 2 , Fort Worth, United States
4 December 2020, 21:16
I'm unable to get the print method to display 4 times. I'm not sure what I need to fix. I typed in System.out.println("print); but it only displays 3 times....
chan kenneth
Level 7 , Hong Kong, Hong Kong
21 January, 07:37
you need a for loop to display the 3 sentences 4 times.
Steven
Level 3 , United States
24 November 2020, 17:01
Ok, so I just gave up and downloaded the correct solution, looking at what the correct solution is I am still confused. Why does is it when I type in "system.out.println(s);" does it print out what it is supposed to? how does it know that s is the text that is being printed? how does it know to print it out 4 times?
Alex
Level 41 , Solar System
25 November 2020, 12:33
The print() method takes a String as an argument and as that argument you pass it a certain string in the main() method when you call the print() method. This shows the print() method that it needs to do something with the string that you "feed" to it. In our case, the print() method needs to print out the string four times. So, when you call the print() method three times with three different strings, the print() method will print out each one four times.
Jake Sjoberg
Level 3 , Detroit, United States
25 December 2020, 00:06
I was able to complete this through trial and error, but I essentially ended up in the same situation. I think what we are asking for is a clearer example of, how does s instantly link those lines of text. I think I grasp that the print method is using Strings as an argument, but how is it connecting the two. Through a beginner's eyes, it looks as if something is missing. Like there should be something else there to tell us that s is correlating those strings. If it's not needed, what are we looking for/missing?
Alex
Level 41 , Solar System
27 December 2020, 13:04
String s is the print() method's argument, which in Java syntax speak means that this method takes in a String variable and needs to do something with it. In the main method, we then provide/feed different strings to our print() method for processing.
mastere
Level 9 , Rochester, United States
25 September 2020, 03:14
For anyone who is stuck with this an example that shows one way to do this is shown in the level 2 lesson titled: Calling methods, returning values at the top of the lesson page. However I used a while loop to do mine when I completed this and I have seen others use a for loop. I hope this helps anyone who is stuck... I think they intend for you to come back to some of the tasks later on if you have trouble with them.
Barbara Fu
Level 2 , Seoul
10 November 2020, 06:09
Except that Level 2 lesson "Calling methods" is locked for now. CodeGym is beginning to frustrate me. Perseverance, okay, hunting down solutions, okay, but as a teacher I know that frustrating your students does not help them learn. This isn't teaching me java--it's teaching me to distrust CodeGym.
Tamas Horcsak
Level 16 , Leeds, United Kingdom
16 September 2020, 16:11
Actually you need to print it out all together 12 times. three message 4 times