Java String Multiply multiply(String self, int reps)

Here you can find the source of multiply(String self, int reps)

Description

reps repitions of self

License

Open Source License

Declaration

static public String multiply(String self, int reps) 

Method Source Code

//package com.java2s;
/*/* w ww  .  jav  a 2s  .  c  om*/
The contents of this file are subject to the Electric Communities E Open
Source Code License Version 1.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License
at http://www.communities.com/EL/.
    
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
    
The Original Code is the Distributed E Language Implementation, released
July 20, 1998.
    
The Initial Developer of the Original Code is Electric Communities.
Copyright (C) 1998 Electric Communities. All Rights Reserved.
    
Contributor(s): ______________________________________.
*/

public class Main {
    /**
     * reps repitions of self
     */
    static public String multiply(String self, int reps) {
        StringBuffer buf = new StringBuffer(self.length() * reps);
        for (int i = 0; i < reps; i++) {
            buf.append(self);
        }
        return buf.toString();
    }
}

Related

  1. multiply(final CharSequence str, final int factor)
  2. multiply(final String s, final Long factor)
  3. multiply(final String string, final int times)
  4. multiply(String original, int times)
  5. multiply(String str11, String str22)
  6. multiplyString(String s, int count)
  7. multiplyString(String sourceStr, int count)
  8. multiplyStringWithInt(String strMultiplicand, int multiplier)