Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a Character  RSS feed

 
Ekrem Altintas
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char kar;
String satir;
int b;
char kar;
...
kar=satir.charAt(b);
if(kar=="<")
{
...
}

I'm writing a code, but I'm taking " operator == cannot be applied to char,java.lang.String - if(kar=">") " error.How can I resolve this problem?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A literal in double quotes is a String. Put it in single quotes to make it a char.

if ( kar == '<' ) ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!