• 06 October

    Convert char to lowercase java

    You can use Character class’s toLowerCase method to convert char to lowercase in java. Method signature [crayon-6729cf47689f4449368923/] Parameters ch is primitive character type. Return type return type is char. If char is already lowercase then it will return same. [crayon-6729cf47689fc762990729/] When you run above program, you will get below output: a y b z That’s […]

  • 06 October

    Convert char to uppercase java

    You can use Charater class’s touppercase method to convert char to uppercase in java. Method signature [crayon-6729cf4768c57479361202/] Parameters ch is primitive character type. Return type return type is char. If char is already uppercase then it will return same. [crayon-6729cf4768c5b269124015/] When you run above program, you will get below output: A Y F U That’s […]

  • 06 October

    Java isLetter method

    Character class’s isletter method can be used to check if character is letter or not. Method signature [crayon-6729cf4768d14003132258/] Parameters ch is primitive character type. Return type boolean is primitive character type. [crayon-6729cf4768d18015918621/] When you run above program, you will get below output: true true false false That’s all about java Character’s isletter method.

  • 21 October

    Difference between equals() and == in java

    In this post, we will see about the difference between equals and == in java. This is most asked java interview question for fresher or 2-year experienced java developer and it might be confusing sometimes. Let’s try to understand each quickly. Equality operator “==” Equality operator can be used to compare primitives but when you […]

  • 30 September

    Longest common substring

    If you want to practice data structure and algorithm programs, you can go through 100+ data structure and algorithm programs. In this post, we will see how to find the longest common substring in java. Program Given two String, find longest common substring. For example: String 1: Java2blog String 2: CoreJavaTutorial Longest common subString is: […]

  • 27 September

    Print maximum occurring character in a String

    In this post, we will see how to print the maximum occurring character in a String. Problem Print maximum occurring character in a String For example: String 1: java2blog tutorial Character: a has occurred maximum times in String: 3 ———————- String 2: This is test message Character: s has occurred maximum times in String: 5 […]

  • 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-6729cf476956f669001601/] 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-6729cf47697d1019197720/] 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.