How do I copy char array to string?

package org.kodejava.lang;

public class CharArrayCopyExample {
    public static void main(String[] args) {
        char[] data = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};

        // Copy all value in the char array and create a new string out of it.
        String text = String.valueOf(data);
        System.out.println(text);

        // Copy a sub array from the char array and create a new string. The
        // following line will just copy 5 characters starting from array index
        // of 3. If the element copied is outside the array index an
        // IndexOutOfBoundsException will be thrown.
        text = String.copyValueOf(data, 3, 5);
        System.out.println(text);
    }
}

The result:

abcdefghij
defgh

How do I convert primitive boolean type into Boolean object?

The following code snippet demonstrate how to use the Boolean.valueOf() method to convert primitive boolean value or a string into Boolean object. This method will return the corresponding Boolean object of the given primitive boolean value.

When a string value is passed to this method it will return Boolean.TRUE when the string is not null, and the value is equal, ignoring case, to the string "true". Otherwise, it will return Boolean.FALSE object.

package org.kodejava.lang;

public class BooleanValueOfExample {
    public static void main(String[] args) {
        boolean b = true;
        Boolean bool = Boolean.valueOf(b);
        System.out.println("bool = " + bool);

        // Here we test the conversion, which is likely unnecessary. But
        // here is shown the boolean true is equals to Boolean.TRUE static
        // variable and of course you can guest the boolean false value is
        // equals to Boolean.FALSE
        if (bool.equals(Boolean.TRUE)) {
            System.out.println("bool = " + bool);
        }

        // On the line below we convert a string to Boolean, it returns
        // true if and only if the string is equals to "true" otherwise it
        // returns false
        String s = "false";
        Boolean bools = Boolean.valueOf(s);
        System.out.println("bools = " + bools);

        String f = "abc";
        Boolean abc = Boolean.valueOf(f);
        System.out.println("abc = " + abc);
    }
}

The code snippet will print the following output:

bool = true
bool = true
boolS = false
abc = false