This question already has an answer here:
- How do I compare strings in Java? 23 answers
-
When I run this code, the first question "Do you want to enter manually or automatically get today's date" pops up. 2.After typing in automatic or manually, the code stops and never executes the if statements. Why? and what can I do to fix it? 3.I tried to make user input boolean, but I don't think that's possible.
package basic; import java.util.Calendar; import java.util.Scanner; public class GetData { public static void main(String[] args) { Scanner option = new Scanner(System.in); System.out.println("Do you want to enter manually or automatically get today's date?"); String choice = option.nextLine(); if(choice =="manually") { System.out.println("Type in date"); Scanner scan= new Scanner(System.in); System.out.println(scan); }
Aucun commentaire:
Enregistrer un commentaire