samedi 4 avril 2015

java if statement to call method

Quick easy question


Is it possible to have an if statement that is based on user input. For example, I want something like this:



System.out.print("Database: ");
Scanner sp = new Scanner(System.in);
String p;
p = sp.nextLine();


If string p = ("mysql")
then call method x
else if
call method y


I have edited the question for clarity, I understand how to receive the user input I am just unsure of the if statement syntax, or even how to word it.


Aucun commentaire:

Enregistrer un commentaire