can any help me with this
print method
Under discussion
Comments (10)
- Popular
- New
- Old
You must be signed in to leave a comment
Anonymous #10428383
10 April 2019, 04:38
Pay attention on the requirements 3, 4, 5:
3. The print method should display the text on the screen.
4. The main method should call the Solution class's print method exactly twice.
5. The print method should display the string 4 times. Each time, on a new line.
Explained : on this step 3. you need to write the code println inside the method print
like this: System.out.println(s); on step 4. is right you did. calling the method print(" Java is easy....");
now you need the last setp 5. repeat the step 3 only. then will print the sentences 4 times
0
Java
10 April 2019, 04:01
Guys use for loop in print method to print 4 times problem solve.
0
Connor
10 April 2019, 19:17
package com.codegym.task.task02.task0201;
Could you explain the for loop a little more in this situation?
This is what I tried, and I couldn't figure out how to get it working.
/*
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) {
For( s = 0; s < 5; s ++){
System.out.println(s);
}
}
}
0
Alex Vypirailenko Java Developer at Toshiba Global Comme
16 August 2018, 07:06
Look into for loops in Java.
One simple line within a for loop in the print method and you're done.
0
Shubhaditya Maljonia
15 August 2018, 18:09
print s 4 times. (That's the solution of this program)
0
Usman Jutt
15 August 2018, 06:43
/* The comment was deleted */
0
Roman
15 August 2018, 08:12
you may use system.out.println() :)
0
Usman Jutt
15 August 2018, 06: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) {
//write your code here
}
}
In the print method, display the passed string 4 times. Each time, on a new line.
Requirements:
1. The program should display text on the screen.
2. The main method should not call System.out.println or System.out.print.
3. The print method should display the text on the screen.
4. The main method should call the Solution class's print method exactly twice.
5. The print method should display the string 4 times. Each time, on a new line.
0
Jobin John
14 August 2018, 16:07
Please specify the exact issue that you are facing with this task.
0
Pavlo Plynko Java Developer at CodeGym
12 August 2018, 14:09
String s - it is passed string. Display it 4 times.
+1