id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

String OperationsConcat4

prev  |  next  |  chance
public static String combine(String s1, String s2) {
    String s3;
    String s4;

    if (s1.length() < 3)
        s3 = s1;
    else
        s3 = s1.substring(0, 1) + s1.substring(s1.length() - 2, s1.length() - 1);

    if (s2.length() < 3)
        s4 = s2;
    else
        s4 = s2.substring(0, 1) + s2.substring(s2.length() - 2, s2.length() - 1);

    return s3 + s4;
}
Function Call  Return Value
combine("Car", "wash")
combine("Hello", " world")
combine("5", "8")
combine("Snow", "ball")
combine("Rain", "boots")
combine("Reading", "bat")
combine("AAA", "Hi")
combine("Hi", "there")
combine(" ", " ")

Experiment with this code on Gitpod.io

⬅ Back