Here you can find the source of mergeStrings(String s1, String s2)
public static String mergeStrings(String s1, String s2)
//package com.java2s; /*/* w ww.ja va 2 s. c o m*/ This file is part of the BlueJ program. Copyright (C) 1999-2009,2011,2012,2013,2014,2015 Michael Kolling and John Rosenberg This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. This file is subject to the Classpath exception as provided in the LICENSE.txt file that accompanied this code. */ public class Main { /** * merge s2 into s1 at position of first '$' */ public static String mergeStrings(String s1, String s2) { int pos = s1.indexOf('$'); if (pos == -1) return s1; else return s1.substring(0, pos) + s2 + s1.substring(pos + 1); } /** * merge strings in s2 into s1 at positions of '$' */ public static String mergeStrings(String s1, String s2[]) { for (int current = 0; current < s2.length; current++) { s1 = mergeStrings(s1, s2[current]); } return s1; } }