## Problem:

Given a string, return a string length 2 made of its first 2 chars. If the string length is less than 2, use '@' for the missing chars.

atFirst("hello") → "he"
atFirst("hi") → "hi"
atFirst("h") → "h@"

## Solution:

public String atFirst(String str) {
if (str.length() >= 2)
return str.substring(0,2);
else if (str.length() == 1)
return str + "@";
else
return "@@";
}

1. public String atFirst(String str) {

if(str.equals(""))
return str + "@" +"@";

if(str.length()<2)
return str +"@";

String s = str.substring(0,2);
return s;
}

2. public String atFirst(String str) {
if(str.length()==0)
{
return "@@";
}
if(str.length()<2)
{
return str+"@";
}
return str.substring(0,2);

}

3. public String atFirst(String str) {
return str.length()>=2?str.substring(0,2):str.length()==1?str+"@":str+"@@";
}

4. public String atFirst(String str) {
if(str.isEmpty()){
return "@@";
}
if(str.length() == 1){
return str + '@';
}
return "" + str.charAt(0) + str.charAt(1);
}

5. “TUIT” -> “UI”
sorry

6. public String atFirst(String str) {
String a="@";
if(str.length()>=2){
return str.substring(0,2);
}
if(str.length()<2 && str.length()>0){
return str.substring(0).concat("@");
}
if(str.isEmpty()){
return a+a;
}return str;
}

7. public String lastChars(String a, String b) {
String first = "";
first = a.length()< 1 ? "@" : a.substring(0,1);
String last = "";
last = b.length()< 2 ? "@" : b.substring(b.length() -1, b.length());
return first + last;

}