Java Coding
In java, to remove all consonants from a given string we can use conditional statements such as if-else or looping statements such as for loops. For example, given input string is “Hi”, then the output should be “i” after removing the consonants from the string. In this article we will learn to remove all consonants […]
In Java, to remove all vowels from a given string, we can use loop concepts such as a while loop or a for loop. For example, if the input string is “Vowel”, then the output string after removing the vowels from input string is “Vwl”. In this article we will learn how to remove vowels […]
In Java, we can find the lowest frequency character in a string using either ASCII values or Maps from the Collection framework. If the input string is “add”, then ‘a’ is the least occurred character in the given string “add”. In this article we will learn to finding lowest repeated character in a string through […]
In Java, we can find the highest frequency character in a string using either ASCII values or Maps from the Collection framework. If the input string is “all”, ‘l’ is the highest occurred character in the input string “all”. In this article we will learn how to find highest frequency in a string through example, […]
In Java, to print the frequency/occurrence of each character in a string, we can use ASCII values or collection frameworks like Maps. For the input string “Java”, the occurrences of each character are: J-1, a-2, and v-1. In this article we will learn how to count the frequency of each character in a string through […]
In java, to remove last character from a string we can use substring() method or wa can also achieve this by creating a custom method. For the given input string “Hello”, after removing the last character from the input string, resulting output will be “Hell”. In this article we will learn to remove last letter […]
In Java, to print the first character in a given string, we can use built-in functions such as charAt(), toCharArray(), substring() or obtain the first character using an if-else statement. For the given input string “Interview”, First character in the string is ‘I’. In this article we will learn how to print first character in […]
In Java, to count total number of words in a string we can use in-built function such as split() method or whitespace counting approach or we can also create a custom method. For instance, “I love programming” contains 3 words, resulting the word count to 3. In this article we will learn how to count […]
In Java, to print the frequency of alphabets, digits, and special characters in a string, we can use loop constructs such as a for loop or a while loop. For instance, if the input string is “Print#$21”, then in the given string there are: 1 uppercase letter, 4 lowercase letters, 2 digits, and 2 special […]
In Java, converting an uppercase string to a lowercase string is a common and simple task. This can be done using Java’s built-in toLowerCase() method or manually through loops and character manipulation. For example, the input string “HELLo” should be converted to “hello”, where all uppercase letters are changed to their lowercase equivalents while other […]