Q:

Simple Java Query - Getting a Result from a String

I have been trying to learn Java for the past few days so my my knowledge is incredibly basic.
I cannot for the life of me work out how to search for the answer to my question online.
I am trying to create a very simple currency converter. The user inputs a currency symbol, then using an IF statement I want to specify the value of 'currencyamnt'
I want to essenially 
if ( currency = "£"  )

    {
        currencyamnt = 1;
    }

currency being a string and currencyamnt being an float.
This doesnt work and i am not sure why..

A:

In java you have to use the .equals to check if a string is equal to some other string. In something like c++ this is valid but for java instead of doing this:  
if ( currency == "£"  ) {
    currencyamnt = 1;
}

try
if ( currency.equals("£")) {
    currencyamnt = 1;
}

Edit: 
The original code looked like this:  
if ( currency = "£"  ) {
    currencyamnt = 1;
}

Which would have set currency to £ instead of checking whether it was equivalent text which is something to always look out for when coding!

