Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
User=e.getKeyChar();

for(int j=0;j<str[no].length();j++){
    if(User==text[j])

char r=User;
          String  s=Character.toString(r);
           System.out.print(s)
}

What I have tried:

char r=User;
          String  s=Character.toString(r);
           System.out.print(s)
Posted
Updated 7-Jul-19 3:56am
Comments
Richard MacCutchan 7-Jul-19 11:54am    
Why not just read a complete string in the first place?

1 solution

Try:
Java
String User = Character.toString(e.getKeyChar());

for(int j = 0; j < str[no].length(); j++){
    if(User == text[j])
Though I'd suspect that
Java
String User = Character.toString(e.getKeyChar());

for(int j = 0; j < text.length(); j++){
    if(User == text[j])
Would be a better idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900