Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-27-2011, 05:34 PM #1
- Join Date
- Feb 2011
- Thanked 0 Times in 0 Posts
Instance Variable Changes with New Object
I'm just learning java and I'm writing a program that compares the frequency of characters in a plaintext document and then in a cipher document. I use the frequencies of the letters in each document to find out which character goes with which, in order to decipher a text file.
I have a class FrequencyAnalysis, which creates an object, with a local variable of char key, in which the letters are stored in order of most common occurrence. I create a FrequencyAnalysis object for the plain text document, and the key is stored fine in its array, but when I create a FrequencyAnalysis object for the ciphered text, the key for the plain text document changes to the key for the ciphered document. Why does this happen?
I have attached the two classes, FrequencyAnalysis and then the class FrequencyAnalysisTester which creates the objects to this post.
03-04-2011, 10:43 PM #2
- Join Date
- Mar 2011
- Thanked 1 Time in 1 Post
because of this..
private static final char alphabet ..
Remove static, It will work for you(because it worked for me)