The print method should display the string 4 times. Each time, on a new line.
Under discussion
Comments (12)
- Popular
- New
- Old
You must be signed in to leave a comment
Hafsah Jilanee
11 November 2018, 16:11
write the println command the number of times you want the line to be printed
0
Parag Gaikwad
10 November 2018, 15:18
I cannt understand how to solve this problem please help me out to solve this problem
0
Grigore Turcan
29 October 2018, 20:41
package com.codegym.task.task02.task0201;
/*
Implement the print method
*/
public class Solution {
public static void main(String[] args) {
print("Java is easy to learn!");
print("Java opens many opportunities!");
}
public static void print(String s) {
System.out.println(s);
System.out.println(s);
System.out.println(s);
System.out.println(s);
}
}
+1
mukesh
19 October 2018, 16:16
System.out.println(print s);
0
Khurram
19 October 2018, 05:58
what seems to be the problem that you are having?
0
rishabh
19 October 2018, 06:02
error on getting that The print method should display the string 4 times. Each time, on a new line.
0
Khurram
19 October 2018, 06:06
can you share the code
0
rishabh
19 October 2018, 06:11
public class Solution {
public static void main(String[] args) {
print("Java is easy to learn!");
print("Java opens many opportunities!");
}
public static void print(String s) {
//write your code here
}
}
0
Khurram
19 October 2018, 06:13
your print function is empty, type your code there
0
rishabh
19 October 2018, 06:55
means
0
Khurram
19 October 2018, 10:15
you have not implemented the print function
0
Hafsah Jilanee
11 November 2018, 16:16
in line 3, print("Java is easy to learn");
as soon as the compiler reads "print" it moves to the "print" method. and whatever is within the parenthesis, that is, "Java is easy to learn" is passed onto String s.
now string s has the value of "Java is easy to learn".
you want to print this passed string 4 times so use the println command.
hope that solves your problem:)
+2