YOOO CAN ANYONE SOLVE THIS IN JAVA??
![YOOO CAN ANYONE SOLVE THIS IN JAVA class=](https://us-static.z-dn.net/files/db1/d49bb16d0654b11aca17db2a21f0f6a2.png)
public class JavaApplication80 {
public static String swapLetters(String word){
char prevC = '_';
String newWord = "";
int count = 0;
if (word.length() % 2 == 1 || word.isBlank()){
return word;
}
else{
for (int i = 0; i<word.length(); i++){
char c = word.charAt(i);
if(count % 2 == 1){
newWord += (c +""+ prevC);
}
prevC = c;
count+=1;
}
}
return newWord;
}
public static void main(String[] args) {
System.out.println(swapLetters("peanut"));
}
}
This works for me. Best of luck.