repeat string in java

public class Main 
{
    public static void main(String[] args) 
    {
        String str = "Abc";
 
        String repeated = new String(new char[3]).replace("\0", str);
 
        System.out.println(repeated);
    }
}

4.4
5
Jchen76201 105 points

                                    public static String repeat(String s, int n) {    StringBuilder sb = new StringBuilder(str.length() * n);    for (int i = 0; i < n; i++)        sb.append(s);    return sb.toString();} public static void main(String[] args) {    System.out.println(repeat("ha", 5));}

4.4 (5 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
what's string.repeat java java 8 repeat string java repeat string java 8 java repeat sting repeat string java 8 string repeat java 8 string repeat java java String.repeat java repeat method repeat java how to repeat string in java .repeat java string repeat method java java 8 string repeat method repeat() string java java repeate string * repeat java what does java string method repeat does repeat function in java java how to repeat a program string repeat match java how to repeat a string in java repeat() java string . repeat java repeat stringjava function repeat stringjava java string repeat character java repeat repeat() in java repeat java code how to repeat something in java java repeat string c# get n times x c# write a string x times c# diplay a letter x amount of times repeat string int times repeating string java return string x c# how to repeat int multiple times print string x times c# how to print substing n times java string sequence n- repeat word n times algorithm print repeting string java string.repeat java repeat method in java repeat a particual function in java repeat a string n times java how to repeated strings c# write character multiple times till the end of line repeat string in java public static String repeat(String text, int times) repeat string on java repeat string java print multiple characters depending on integer input c# create substring from an long string n times c# c# repeat a character x times text string x times change c# repeat string x times c# repeat a word number of times asked add string n times java how to repeat a string java string repeat end equal 4 times string equal 4 times string repeat a string n times c# how to repeat a string based on an int c# how to repeat a string n times in java Return one string that is the given string repeated n times write out a string multiple times c# repeat character x times
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source