java convert char to string .charAt(). Java logic programming question with answer.
-Given 2 strings, a and b, return a new string made of the first char of a and the last char of b, so "yo" and "java" yields "ya". If either string is length 0, use '@' for its missing char.lastChars("last", "chars") → "ls"
lastChars("yo", "java") → "ya"
lastChars("hi", "") → "h@"
Solution :
public String lastChars(String a, String b) {
String n;
int l2= a.length();
int l3= b.length();
char co,ct;
if (l2 == 0)
co ='@';
else
co = a.charAt(0);