user3552903
user3552903

Reputation: 1

Lexicography in Java

If I wanted to simply replace a letter or a number with one immediately preceding it, how would I go about that? For example, I wanted to replace the letter 'c' with 'b' in my code, or 3 with 2. Any tips?

Upvotes: 0

Views: 112

Answers (1)

Andrew McGuinness
Andrew McGuinness

Reputation: 2147

The "char" type is numeric, and you can subtract one from it to get the answer you want. Work out what you want to do with '0' or 'a'.

Upvotes: 1

Related Questions