dimanche 24 mars 2019

Coding Help (If Statements)

Let's say I have a sample code, something like this

public double {method} ()
{
if (stringThatCalledThisMethod.equalsIgnoreCase("x")) // x = A String
{
return 100 ;
}
else if (stringThat....equalsIgnoreCase("y"))         // y = A String
{
return 999 ;
}

How would I call for the string that called that method? (In this instance any string can call for the method and it will always be different)

(Using this does not work as I get an error saying "Cannot find Symbol | symbol: method equalsIgnoreCase(String)

I am trying to convert a string to a double (Not sure if there is an easier way)

Aucun commentaire:

Enregistrer un commentaire