CodeGym
Promotion
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
Steve
Level 6
Hartford
  • 03.06.2020
  • 368views
  • 1comment

Last 2 conditions not met but when i test it my output seems to work

Question about the task StringHelper class
Java Syntax,  Level 6,  Lesson 8
Under discussion


Make the StringHelper class, which will have 2 static methods:
String multiply(String s, int count) - returns a string that has been repeated count times.
String multiply(String s) - returns a string that has been repeated 5 times.

For example:
Amigo -> AmigoAmigoAmigoAmigoAmigo

Requirements:
  • The program must not read data from the keyboard.
  • The StringHelper class's methods must return a string.
  • The StringHelper class's methods must be static.
  • The StringHelper class's methods must be public.
  • The multiply(String s, int count) method must return a string that has been repeated count times.
  • The multiply(String s) method must return a string that has been repeated 5 times.
package com.codegym.task.task06.task0611; /* StringHelper class */ public class StringHelper { public static String multiply(String s) { String repeat = ""; String result = (s + " -> "); for (int i=0; i<5; i++) repeat = repeat + s; result = result + repeat; return result; } public static String multiply(String s, int count) { String result = (s + " -> "); String repeat = ""; for (int i=0; i<count; i++) repeat = repeat + s; result = result + repeat; return result; } public static void main(String[] args) { } }
0
Comments (1)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Ashish RajAnand
Level 13 , Bhilai , India
4 June 2020, 02:21useful
it is work like that if you call method
multiply(Hii)
then output like this HiiHiiHiiHiiHii but your output Hii->HiiHiiHiiHiiHii
+1
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.