How do I convert string to an integer or number?

package org.kodejava.example.lang;

public class StringToInteger {
    public static void main(String[] args) {
        // Some random selected number, could representing a decimal,
        // hexadecimal or octal number.
        String myLuckyNumber = "13";

        // We convert a string to an integer by invoking parseInt() method
        // of the Integer class.
        Integer number = Integer.parseInt(myLuckyNumber);
        System.out.println("My lucky number is: " + number);

        // We can also converting a string representation of a number other
        // then the decimal base, for instance an hexadecimal by providing
        // the radix to the method.
        number = Integer.parseInt(myLuckyNumber, 16);
        System.out.println("My lucky number is: " + number);

        number = Integer.parseInt(myLuckyNumber, 8);
        System.out.println("My lucky number is: " + number);
    }
}

Our code results are:

My lucky number is: 13
My lucky number is: 19
My lucky number is: 11

How do I convert string to char array?

Here we have a small class that convert a string literal into array, a character array.

package org.kodejava.example.lang;

public class StringToArrayExample {
    public static void main(String[] args) {
        // We have a string literal that contains the motto of this website.
        String literal = "Kode Java - Learn Java Programming by Examples";

        // Now we want to convert or divided it into a small array of char.
        // To do this we can simply used String.toCharArray() method. This
        // method splits the string into an array of characters.
        char[] temp = literal.toCharArray();

        // Here we just iterate the char array and print it to our console.
        for (int i = 0; i < temp.length; i++) {
            System.out.print(temp[i]);
        }
    }
}