String
- 19 January
How to Compare Two Strings in Java
In this post, we will see how to compare two String in java. As you might know, String implements Comparable interface, you can use compareTo method to compare two String in java. [crayon-6729cedd3c70f261271513/] Output: Enter First String : Java Enter Second String : Blog First String is Greater than Second String. That’s all about How […]
- 19 January
Java Program to Check Whether a Character is Alphabet or Not
This tutorial provides Java Program to Check Whether a Character is Alphabet or Not. [crayon-6729cedd3dba9567877743/] Output: Enter a Character : d d is an alphabet. The ASCII value of lowercase alphabets range from 97 to 122. And, the ASCII value of uppercase alphabets range from 65 to 90. That’s why, we compared variable character between […]
- 19 January
Java Program to check a Character is Vowel or Consonant
In this post, we will see how to check a Character is Vowel or Consonant. You just need to check if character is part of set {a,A,e,E,i,I,o,O,u,U}.If it is part of set then it is Vowel else Consonant. [crayon-6729cedd3dc7c760593071/] Output: Enter an Alphabet : g g is a Consonant That’s all about Java Program to […]
- 10 November
Java String matches example
In this post, we are going to see String’s matches method. String’s matches method String matches method is used to check whether the string is matched with the given regular expression.In normal terms, we can pass various regular expressions to check if the specified string matches with that regular expression.If the matches get successful return […]
- 10 November
Java List to String
In this post, we will see how to convert List to String in java. Following are the ways to convert list into String: Using StringBuilder We can use StringBuilder class to convert List to String. StringBuilder is the best approach if you have other than String Array, List.We can add elements in the object of […]
- 04 November
How to convert String to Double in Java
With the introduction of different data types, the need for conversion of one data type to another has come into being. In this article, we are going to see how we can convert from a String data type into Double data type. Conversion Modes There are two ways in which String data can be converted […]
- 04 November
How to convert String to int in Java
In this article, we are going to see how we can convert from a String data type into integer data type in Java. Conversion Modes There are two ways in which String data can be converted into integer. They are: Using the static method parseInt(String) of the java.lang.Integer wrapper class Using the static method valueOf(String) […]
- 27 October
Count number of words in a string
In this post, we will see how to find number of words in a String. Problem Find the number of words in a String. For example: There are 6 words in below String welcome to java tutorial on Java2blog Algorithm The algorithm will be very simple. Initialize count with 1 as if there are no […]
- 28 September
Java String Replace
Java String replace method replaces all occurrences of old char to new char or old CharSequence to new CharSequence and return new String. If there is nothing to replace in the String, it will return same String. Let’s say you need to convert "Java2blog" to "JavaTwoblog", you can simply use below syntax. [crayon-6729cedd3e37b420493674/] Syntax There […]