About 260,000 results
Open links in new tab
  1. java - How to get boolean user input using scanner ... - Stack Overflow

    Feb 6, 2015 · Scanner n = new Scanner(System.in); boolean bn = s.nextBoolean(); if (bn == true) { // do stuff } else if (bn == false) { // do stuff } } catch (InputMismatchException e) { System.out.println("Invalid input!"); } } while (!b);

  2. Scanner nextBoolean() method in Java with Examples

    Oct 12, 2018 · The nextBoolean() method of java.util.Scanner class scans the next token of the input as a Boolean. If the translation is successful, the scanner advances past the input that matched. Syntax: public boolean nextBoolean() Parameters: The function does not accepts any parameter. Return Value: This function returns the Boolean scanned from the input.

  3. Java Scanner nextBoolean() Method - W3Schools

    The nextBoolean() method returns the boolean value that the next token represents. A token represents a boolean value if its value matches one of the strings "true" or "false". The match is case-insensitive, which means that values like "True" and …

  4. java - Yes/No with boolean or if/else? - Stack Overflow

    Apr 10, 2013 · I'm having issues creating a yes/no input in my program. I want the user to be able to input a y/n after the last print statement, but i'm not quite sure how I would implement it. I know it would most likely include a boolean or an if/else statement, but i'm not quite sure. Any help?

  5. Java Booleans - W3Schools

    A Boolean expression returns a boolean value: true or false. This is useful to build logic, and find answers. For example, you can use a comparison operator , such as the greater than ( > ) operator, to find out if an expression (or a variable) is true or false:

  6. Java User Input (Scanner class) - W3Schools

    Java User Input. The Scanner class is used to get user input, and it is found in the java.util package. To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. In our example, we will use the nextLine() method, which is used to read Strings:

  7. Java Scanner nextBoolean() Method - Online Tutorials Library

    Java Scanner nextBoolean Method - Learn how to use the nextBoolean method of the Scanner class in Java to read boolean values from user input. Get examples and explanations.

  8. Java User Input – Scanner Class - GeeksforGeeks

    Apr 22, 2025 · The most common way to take user input in Java is using the Scanner class. It is a part of java.util package. The scanner class can handle input from different places, like as we are typing at the console, reading from a file, or working with data streams. This class was introduced in Java 5. Before

  9. java - How can get boolean user Input - Stack Overflow

    Aug 26, 2017 · When I input in the program like this: boolean a = (true & false) & true; It's worked. But when I input from the keyboard by using Scanner: Scanner sc = new Scanner(System.in); boolean b...

  10. Take input from a user and use it in a boolean function using Java ...

    Oct 1, 2014 · Java: Trying to take keyboard input and evaluate it in an if/else condition to set a boolean value to true or false

Refresh