First try Caesar Cipher I've recently begun to teach myself to code. One simple project that I wanted to do was create a Caesar cipher that works well. Now that I feel I've accomplished that task, I'd like to know how I'm doing with overall code quality. Here's the code.

import java.util.Scanner;

public class Encryptor 
{
    private char[] upperCase = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
    private char[] lowerCase = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
    private char oneChar;
    private String encryptedString = "";
    private int counter;

    public String encryptString(String input, int offset)
    {
        for (counter = 0; counter &lt; input.length(); counter++)
        {
            oneChar = input.charAt(counter);

            boolean moveOn = false;
            int i = 0;

            //get a single character

            while (!moveOn)
            {
                if (i &gt; 26)
                {
                    encryptedString += oneChar;
                    moveOn = true;
                }
                //remainder keeps me from going over array length
                else if (oneChar == upperCase[i%26])
                {
                    encryptedString += upperCase[(i+offset)%26];
                    moveOn = true;
                }
                else if (oneChar == lowerCase[i%26])
                {
                    encryptedString += lowerCase[(i+offset)%26];
                    moveOn = true;
                }
                else
                {
                    i++;
                }
            }
        }
        return encryptedString;
    }
}


public class Main 
{
    public static void main (String[] args)
    {
        String inText = "";
        String encryptedText = "";
        int offset = 0;
        String choice;

        Scanner input = new Scanner(System.in);

        System.out.println("Enter something to encrypt or decrypt");
        inText = input.nextLine();

        System.out.println("Would you like to encrypt your message, or decrypt your message? Please type in encrypt or decrypt.");
        choice = input.next();

        System.out.println("How many letters over should the program shift everything? Enter numbers only.");
        offset = input.nextInt();

        Encryptor encrypt = new Encryptor();
        if (choice.equalsIgnoreCase("encrypt") || choice.equalsIgnoreCase("e"))
        {
            encryptedText = encrypt.encryptString(inText, offset);
        }
        else if (choice.equalsIgnoreCase("decrypt") || choice.equalsIgnoreCase("d"))
        {
            offset = 26 - offset;
            encryptedText = encrypt.encryptString(inText, offset);
        }
        System.out.printf("Your message is %s", encryptedText);

        }

    input.close();

    }
}


What do you think of it in terms of overall readability? And for a first attempt, how'd you rank it?

EDIT: Adding in some more questions that occurred overnight.

What things in this make you cringe/confused/ need to be improved?
I noticed that during decryption, if the offset goes below 0, I get an index out of range error. For example, if some joker decides to offset more than 26, say 27, the offset becomes -1. This is then subtracted and ran through the remainder and comes out negative. A negative value in an array is an error. I can't simply do the absolute value of the number either as the way my code and arrays are set out, -1%26 would not be 1%26, rather -1%26 should be equivalent to 25.
It would seem that you are restricting yourself to English alphabet, when there is no need for that. All that Caesar cipher does, is adding some constant (usually called key) to each character. Decoding then may be done by subtracting that very key from each encoded character. All in all, I had this in mind:

public class Encryptor {

    public static String encryptString(String input, int key) {
        StringBuilder sb = new StringBuilder(input.length());

        for (char c : input.toCharArray()) {
            sb.append((char)(c + key));
        }

        return sb.toString();
    }

    public static String decryptString(String input, int key) {
        return encryptString(input, -key);
    }
}


Also, using StringBuilder
will improve the performance of your cipher: when you do

char c = '?';
myString += c;


a new String is created which runs in linear time as it needs to copy the character content. However, appending to a StringBuilder of a known size runs in constant time.

I run your program, and it does not cipher the white-space. This makes breaking your cipher easier as the attacker will see clearly the lengths of words. Instead, cipher any character in the input string.