• 08 June

    Java enum with String

    In this quick tutorial, how to create String constants using enum, convert String to enum etc. You can go though complete enum tutorial here. Let’s create java enum String constants. Create java enum String [crayon-6095385b031af009250033/] That’s pretty simple. Access enum by name You can simply use . operator to access enum but if you have […]

  • 20 January

    Program to find frequency of characters in a string in java

    In this tutorial, we will see simple program to find frequency of characters in a string in java. There are multiple ways to solve this proble. Let’s see one by one. Using counter array Here is the algorithm for the same. Initialize counter array of 256 length Iterate over String and increase count by 1 […]

  • 20 January

    Java program to count number of words in sentence

    In this tutorial, we will see a simple java program to count number of words in sentence. [crayon-6095385b04065765091953/] Output: Enter a Sentence : Java2Blog is a technical blog. Total number of words are 5 That’s all about Java program to count number of words in sentence.

  • 19 January

    Java program to compare two Strings

    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-6095385b0439f870238610/] Output: Enter First String : Java Enter Second String : Blog First String is Greater than Second String. That’s all about comparing […]

  • 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-6095385b046a4927505147/] 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-6095385b04994259999100/] Output: Enter an Alphabet : g g is a Consonant That’s all about Java Program to […]

  • 09 October

    Java program to print vowels in a String

    In this post, we will see how to print and count vowels in a string. Print Vowels in a String If any character in String satisfy below condition then it is vowel and we will add it to Hashset. character==’a’ || character==’A’ || character==’e’ || character==’E’ || character==’i’ || character==’I’ || character==’o’ || character==’O’ || […]

  • 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 […]