I didn't know how to explain the question but hopefully this will make you understand
I know this code does not work
a = "hello";
if (a.equals("hello" || "greetings")){
//Execute code
}
Is there a simple way to do this without an error
I could do this but this means that i will need to repeat codes on both
a = "hello";
if (a.equals("hello")){
//Do code
}
if (a.equals("greetings")){
//Execute code
}
This is my current code but its not what i want it to do.
What i want it to do is if for example topic = "Whats the date";
i want it to execute the code because it contains date, I cant find a way to check if it contains date and so the || works
scanner = new Scanner(System.in);
String topic = scanner.nextLine();
topic = topic.toLowerCase();
if (topic.equals("time") || topic.equals("date")){
System.out.println("The time is " + Calendar.getInstance().getTime());
}