Java – How to parse a string to Boolean object in Java ?

Published on March 9, 2016 by abundantcode

Filed under Java

Last modified March 9, 2016

Print this page

rate 1 star rate 2 star rate 3 star rate 4 star rate 5 star
Your rating: none, Average: 0 (0 votes)

This article have been viewed 4300 times

Problem Statement

You need to parse the string value to the Boolean object in your Java program.

Solution

Use the valueOf static method defined in the Boolean class to parse the string value and convert it to the Boolean object in Java.

public class Main {

    public static void main(String[] args) {

        System.out.println("Abundantcode.com Java Tutorials");

        Boolean b1 = Boolean.valueOf("false");
        System.out.println(b1);

    }
}

Leave a Comment


x

You might be Interested in these Posts

Video - Angular Router - Brian Ford

Video - Angular Router - Brian Ford http://www.youtube.com/watch?v=sfV0ApyN5fM ...

Video - An Angular2 Todo App: First look at App Development in Angular2

In this screencast , David East , one of the core contributor of the Angular provides a glimpse of A...

Video - Getting started with Angular 2

In this screencast , Alex Eagle , developer on the Angular team talks about Angular 2 developer prev...