Read boolean from console using Scanner - Java File Path IO

Java examples for File Path IO:Scanner

Description

Read boolean from console using Scanner

Demo Code

import java.util.Scanner;

public class BooleanInputOutput {

    public static void main(String cLA[]) {

        Scanner myInput = new Scanner(System.in);

        boolean myBool = myInput.nextBoolean(); // true or false

        System.out.printf("%b\n", myBool);
    }//from  w w w.  j  a  v a 2  s.co  m
}

Related Tutorials