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

Dereference  RSS feed

 
Andy Rayner
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is probably very simple
i have:



and i get the error
OutputStream.java:35: char cannot be dereferenced

anyone know why
regards
 
Andy Rayner
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh i forgot, fromServer is a bufferReader and im trying to display the output from a telnet server.

Cheers
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A primitive cannot be "dereferenced" like an object. This is a static method of the Character class (so you call it using the class name rather than an instance), taking a char as the argument...

Character.isLetterOrDigit(c)
 
Andy Rayner
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you how would i account for /n and /r also in the if statment, if i wanted to get all the characters that were letters digits, carriage returns
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's probably a better way, but I believe this would work...

if(Character.isLetterOrDigit(c) || c=='\n' || c=='\r')
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!