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.
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Kenneth FoxLevel 2 , Winston-Salem
Monday, 00:42
So I'm not sure if I'm understanding this correctly, but here's what my thoughts are so far. The first method has 3 commands. The second method assigns Strings to define the first method and everything that is linked to the first method. When you add code under the second method to System.out.println(s); four times it calls all the commands in the first method to generate 4 times each? I don't know if that's how to explain it lol
pratyush prakashLevel 2 , patna
1 July, 10:48
im not understanding lvl2 lesson2 the lesson and task please help
amjLevel 4 , Mumbai
25 June, 05:21
i dont understand calling system in lesson 2-3 they dont teach there at that level.
Maxim FedorovLevel 2 , Philadelphia
22 June, 21:40
this thing says to print it three times then it says to print it four times, i am confused
AlexLevel 41
24 June, 05:07
We are calling the print() method three times from the main() method, but the print() method must have the code inside it which prints the passed string (variable String s) four times. This means that, in our case, by calling the print method three times we will have 12 lines printed in the console (3 different lines each printed 4 times).
Robby WagnerLevel 3 , Tempe
13 June, 23:00
This was tough for me but felt good to figure it out. I read in the help section someone got it using a for loop so looked at some for loop examples on printing however many lines desired and found online. I know we're not supposed to put answers in here but hopefully this gives enough of a hint to find out how to do it.
Sarah Beth BenesLevel 3 , Savannah
8 June, 13:18
... hint. They do not want 4 lines of print. They want the three lines to print 4 times.
AttilaLevel 5 , Hainault
26 May, 13:04
the task has to be implemented
Charles MullinLevel 2 , Harrisburg
11 May, 08:16
Oh, because .using print in the method name print(String s), so print is in the variable name parameter passed from the main method statements? Does that make it the variable String s being declared in the method print ? Although the loop should not be in the main, in the first sample code, at least it is declaring print as a variable . Having print and then a statement in the second solution , I can see where that is declaring a variable but then isnt it declaring the same variable 3 different times which is illegal ? And is the method name, public static void print(String s), working as a call to the print statements in the main ? I am trying to get the specifics on how the print statements in the method print(String s).are called as parameters in the second method in a way that is clear. Like I go to burger king drive through and stop at the speaker and choose my order then the clerk confirms my order and gives me the cost and i drive up and give my card and get charged and get my food .So the order is a parameter passed from the main method- ordering the food, and the second method is the giving the bak card and the charge on the card is a function in the second method and receiving the food. So using "System.out.println(s);" becomes System.out.println("Java is easy to learn!"). I am not certain how the program knows that String s = the print statements because I do not see anything declared. I am confused. I see where String s is called as a parameter in the second method, but where is it called as a variable or linked to the print statements in the main ?
Sarah Beth BenesLevel 3 , Savannah
8 June, 13:20
In main(), you specify what s is. s is an array variable with 3 components, 3 strings.
Billy JohnsonLevel 3 , Blue Ridge
8 April, 23:35
I got it to work after reading everyone's posts. Task instructions were vague at best. I believe that one was just to get everyone talking.
Bradley SnipesLevel 2 , Hartford
21 March, 18:52
Brand new to coding here, but after reading the discussion post I was able to figure this task out. To me I often forget to read the code in between each set of { } way to often. When I remember to to look for each set set of { } and break the code down like that , it seems to help me understand what is going on.