How to convert String to int in Java
In Java, we can use Integer.parseInt(String) to convert a String to an int; For unparsable String, it throws NumberFormatException. We will examine deeply on how to convert String to primitive…
How to convert String to Integer in Java
In Java, we can use Integer.valueOf(String) to convert a String to an Integer object; For unparsable String, it throws NumberFormatException. We will examine deeply on how to convert a String…
Java – How to check if a String is numeric
Few Java examples to show you how to check if a String is numeric. We have several ways to check numeric string: using Character.isDigit(), using NumberUtils.isDigits() from Apache Commons Lang
How to split a string in Java
In Java, we can use String#split() to split a string. We will examine deeply many ways or options to split a string.
Java Regular Expression Tutorial
Java has comprehensive support for Regular Expression functionality through the java.util.regex package. The regular expression language is easy to learn but hard to master, the better way to learn it…
How to compare strings in Java
In Java, we use equals() to compare string value. In this article, we will show you a few ways to compare strings in Java: using equals(), using equalsIgnoreCase(), using contentEquals(),…
Java String compareTo() examples
The Java String compareTo() method compares two strings lexicographically (alphabetical order). It returns a positive number, negative number, or zero. if s1 < s2, it returns negative number. if s1…
How to convert String to byte[] in Java?
In Java, we can use str.getBytes(StandardCharsets.UTF_8) to convert a String into a byte. And we can use new String(bytes, StandardCharsets.UTF_8) to convert byte to a String.
How to convert byte[] array to String in Java
In Java, we can use new String(bytes, StandardCharsets.UTF_8) to convert a byte to a String. For text or character data, we use new String(bytes, StandardCharsets.UTF_8) to convert the byte to…
How to convert String to Hex in Java
Here are a few Java examples of converting between String or ASCII to and from Hexadecimal. Apache Commons Codec – Hex, Integer, Bitwise