CodeGym
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
Online Learner
Level 6
  • 20.06.2019
  • 766views
  • 4comments

i also showed 4 lines but getting an error

Question about the task Implement the print method
Java Syntax,  Level 2,  Lesson 1
Resolved


In the print method, display the passed string 4 times. Each time, on a new line.

Requirements:
  • The program should display text on the screen.
  • The main method should not call System.out.println or System.out.print.
  • The print method should display the text on the screen.
  • The main method should call the Solution class's print method exactly three times.
  • The print method should display the string 4 times. Each time, on a new line.
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 System.out.println(s); System.out.println(s); } }
0
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Soumya shetty
Level 2 , Mumbai, India
25 June 2019, 08:01
as you have to print it 4 times System.out.println(s); write this line 4 times
0
swastik pandey
Level 2 , Bangalore, India
23 June 2019, 12:11
You can pass it by applying for loop in print method, run the loop four times: for(x=0;x<4;x++){ System.out.println(s); }
0
hidden #10468516
Level 5
21 June 2019, 09:49
Four lines are for each String like "Java is easy to learn" 4 times and "Java opens many opportunities" 4 times
0
Online Learner
Level 6
21 June 2019, 19:09
thanks dude
0
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning and Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.