Code Snippets
Runnable Java code examples for testers: arrays, numbers and strings, with output and common mistakes.
Find the Longest Word in a Sentence in Java (Loop, Streams, Ties)
Java program to find the longest word in a sentence: loop and Java 8 stream solutions, handling punctuation, multiple spaces and ties, with complexity.
Check If Two Arrays Are Equal in Java (Arrays.equals, Manual Loop, Any Order)
Java program to check whether two arrays are equal: Arrays.equals, a manual loop, deepEquals, and comparing arrays where order does not matter.
Sort Words Alphabetically Java | Complete Guide
Learn how to sort words in alphabetical order in Java using Arrays.sort(), case-insensitive sorting, and Streams.
Count Character Frequency in String Java | Complete Analysis
Learn how to count character frequency in a Java string using HashMap, Streams, and a character array. Explore code examples, FAQs, and the best methods.
Remove Duplicate Words from Sentence Java | 2 Methods
Learn how to remove duplicate words from a sentence in Java using LinkedHashSet and Streams. Explore code examples, output, FAQs, and the best approach for.
Count Word Frequency in Sentence Java | HashMap Guide
Learn how to count the frequency of each word in Java using HashMap, LinkedHashMap, and Streams. Explore code examples, output, FAQs, and the best approach.
Find Shortest Word in Sentence Java | Quick Guide
Learn how to find the shortest word in a sentence in Java using a loop, Streams, and Collections.min(). Explore code examples, FAQs, and the best approach.
Reverse Word Order in Sentence Java | 3 Methods Explained
Learn how to reverse the order of words in a sentence in Java using Collections.reverse(), Streams, and Stack. Explore step-by-step examples, source code.
Reverse Each Word in Sentence Java | Step-by-Step Guide
Learn how to Reverse Each Word in Sentence Java step by step with code snippets, FAQs.
Count Words in Sentence Java | 4 Methods with Code Examples
Learn how to count words in a sentence in Java using split(), StringTokenizer, regex, Streams, and manual iteration. Includes examples, performance comparison.
Swap Two Characters in String Java | 3 Methods Explained
Introduction Swapping two characters in a string is a common string manipulation task in Java. Although Java strings are immutable, you can still swap.
Check if String Contains Only Alphabets Java | Multiple Methods
Check if String Contains Only Alphabets Java with Multiple Methods explained
Check if String Contains Only Digits Java | Multiple Methods
Introduction Checking whether a string contains only digits is one of the most common validation tasks in Java.
Remove Duplicate Characters from String Java | 4 Methods
Introduction Removing duplicate characters from a string is a common string manipulation problem in Java. It frequently appears in technical interviews.
Find Duplicate Characters in String Java | 4 Methods Explained
Introduction Finding duplicate characters in a string is a common Java programming problem that appears in technical interviews, coding assignments, and.
Check if Strings are Anagrams Java | 4 Methods Explained
Introduction An anagram is a word or phrase formed by rearranging the letters of another word or phrase, using all the original letters exactly once.
Replace Character in String Java | replace() and replaceAll() Methods
Introduction Replacing characters in strings is a fundamental operation for text processing, data cleaning, and string manipulation.
Remove Whitespaces from String Java
Introduction Removing whitespaces from strings is a common requirement in data processing, validation, and text formatting.
Concatenate Strings Without + Operator in Java | 5 Methods Explained
Concatenate Strings Without + Operator in Java | learn all different 5 Methods Explained.
Find String Length Without length() Method in Java | Alternative Methods
Learn alternative methods to find string length without using length() method, including loops, arrays, and stream approaches.