I need to check if Currency.getAvailableCurrencies()
contains
my currency which is a string
I've tried this
if(Currency.getAvailableCurrencies().contains("my currency")){
// do something
}
but that returns false
, but it contains "my currency"
?
Currency.getAvailableCurrencies()
returns Set<Currency>
doc, so you are trying to check String
in Set
of Currency
objects which returns false
always. You need to create Currency
object with the input string, Use Currency.getInstance to get the Currency
instance
if(Currency.getAvailableCurrencies().contains(Currency.getInstance("my currency")))