This site requires JavaScript, please enable it in your browser!
Greenfoot back
rockon411
rockon411 wrote ...

2017/4/26

Defining a String

rockon411 rockon411

2017/4/26

#
So this is going to be a REALLY simple issue that I probably should be able to figure out but I can't. I have to define a String object that I created to be a certain string of letters and numbers. It has the modifiers static and final which I have never used before but have looked up. From what I understand, you can only set the string once, but I am have struggles doing that. Here is what I have so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
private PersonalData personalData;
    private PublicKey publicKey;
    private InputStream inputStream;
    private Scanner scanner;
    private static final String KEY_STRING;
    private String words;
 
    //~ Constructor ...........................................................
    // ----------------------------------------------------------
    /**
     * Creates a new Verifier object.
     */
    public Verifier(PersonalData personalData)
    {
        publicKey = getPublicKey();
        inputStream = personalData.getFileStream();
        scanner = new Scanner(inputStream);
        words = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCSYKkGDPgWHPXR5R87QznlNmRzkd02kRQ5vFygTT0SDOF6tAgrKS178omo3b7JH3qFRse5n2aoMGEKdyzTZNP4ywzuZQQLnpBhanarI2xfqlIyiYaIXHy/qTrUJVfrR8RW7iZUtPygoN2ckvWpaNQiBJg4NVQmkQwWdoIr3dOXEwIDAQAB";
        KEY_STRING = words;
    }
danpost danpost

2017/4/26

#
Try changing line 19 to this:
1
KEY_STRING = new String(words);
(untested)
rockon411 rockon411

2017/4/27

#
Thanks! It worked!
You need to login to post a reply.