i want to write a program that changes all the 'a' charachters to 'v'
but the problem instead prints all the message as vvvvvvvvv
here is the code
class operation
{
public String encode (String args)
{
StringBuilder mago = new StringBuilder();
char a, b;
b='a';
for (int i=0; i<args.length(); i++)
{
a=Character.toLowerCase(args.charAt(i));
if (Character.isLetter(a))
{ a='v';
}
b=a;
mago.append(a);
}
return mago.toString();
}
}
}
the main class
public class trial {
public static void main(String[] args) {
// TODO, add your application code
// To read a sentence from the user
Scanner jack = new Scanner(System.in);
operation z= new operation();
System.out.println(z.encode("i am a programmer"));
}
}
plz help me