Java combining two strings -


i'm trying write function combines 2 strings using rules below.

  1. symbols in string taken turns (first string first symbol, second string first symbol, first string second symbol , on) : "jv" + "aa" = "java".

  2. if shorter string reaches end, symbols string added end of string ended : "h" + "ello" = "hello".

this have far:

    public static void main(string[] args) {         string aa = "jv";         string bb = "aa";         system.out.println(combinestrings(aa, bb));    }    public static string combinestrings(string aa, string bb) {       string newstring;      if(aa.length() > bb.length()){           for(int = 0; < aa.length(); i++){               newstring  = aa.substring(i, 1) + bb.substring(i, 1);           }       } else {        }        return newstring;  } 

so initialize

string newstring = ""; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -