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

 

 

Warmup 1FirstLast

prev  |  next  |  chance
public static String firstLast(String a, String b) {

    String result;
    String aChar;
    String bChar;

    if (a.length() == 0)
        aChar = "$";
    else
        aChar = a.substring(a.length() - 1);

    if (b.length() == 0)
        bChar = "$";
    else
        bChar = b.substring(0, 1);

    result = aChar + bChar;
    return result;
}
Function Call  Return Value
firstLast("Hello", "World")
firstLast("Wow", "Hi")
firstLast("Computational", "Thinking")
firstLast("1143", "994")
firstLast("", "oOf")
firstLast("", "")

Experiment with this code on Gitpod.io

⬅ Back