Search code examples
javarubysymbols

equivalence of Ruby :symbol in Java?


noticed the neat features of ruby symbols here

Does java have anything similar to this? what would it be called?

D don't think a final string would do all the features. especially the way its stored and it would still need a toString for comparison.


Solution

  • A symbol in ruby is just an immutable string. The java equivalent would just be a normal String. I don't really see too many ruby specific features there, except maybe this memory leak one...