By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,654 Members | 1,519 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,654 IT Pros & Developers. It's quick & easy.

i don't understand this method haw it work !!!?

P: 1
Expand|Select|Wrap|Line Numbers
  1. private char encryptChar(char c, int k) {
  2.         if (Character.isLetter(c))
  3.             return (char) ('A' + (c - 'A' + k) % 26);
  4.         else
  5.             return c;
  6.     }
Oct 9 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 10K+
P: 12,421
It's basically a caeser cipher. Meaning that it shifts a character k number of characters forward. With k = 1, a becomes b, b becomes c, c becomes d, z becomes a, etc.
Oct 10 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.