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) {
}
}
After public static void print(String s) { .... i tried ....
1> write.print(s*s);
2> write.print(s+s);
3> return (s);
4> return(s+s);
hi,
I have tried the above 4 ways to get an output. I'm sure it's incorrect.
I could not understand how to print the two lines without System.out.println
Please guide me.
Thank you.
Implement Print method
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Srividya
26 September 2018, 15:34
OK. I got that we can use System.out.println(s);
But I did not get to, print method should display the string 4 times. Each time, on a new line.
0
Ankush Rajput
26 September 2018, 15:22
Read the question carefully. It mentioned that "main" method should not call println.
But print method can call System.out.println.
Pass strings from main to print method and print method will do rest.
0
Srividya
26 September 2018, 15:36
I got the output ... even the last statement.
Thank You. :)
0