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) {
String a= "Java is easy to learn!";
String b= "Java opens many opportunities!";
String c= " ";
s= a+c+b;
printTextMoreTimes(s,2);
}
public static void printTextMoreTimes(String s, int count)
{
for(int i=0; i< count; i++)
{
System.out.println(s);
}
}
}
It's printing 4 lines and still not working where have I gone wrong?
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Gabriel Moldovan
3 January 2021, 15:05
you have two } on the same space
the end need to look like this ;
" }
} "
not like this :
" }
} "
you understand ??
+2
Krushi Vankdoth
4 July 2020, 16:49
instead of dragging the whole code that much,u could have just placed that for loop and print statement in print method........and in for loop intead of count just use 4 .....u will get the output
+1
Guadalupe Gagnon
21 January 2019, 17:05
The output with the passed in values from main should be:
Java is easy to learn!
Java is easy to learn!
Java is easy to learn!
Java is easy to learn!
Java opens many opportunities!
Java opens many opportunities!
Java opens many opportunities!
Java opens many opportunities!
There are many different ways to do this, I'll not give you a correct answer but let your creativity solve this.
0