🆕 Free Interactive Selenium, Playwright & API tools — no signup — Start Free Automation Roadmap →
📁
All Topics › Code Snippets

Code Snippets

Runnable Java code examples for testers: arrays, numbers and strings, with output and common mistakes.

123 Articles
123 Beginner
1 Intermediate
Beginner 📅 Jul 15, 2026 👁 53 views

Count Characters in a String Java | length() Method Explained

Learn how to count characters in Java strings using length() method, with examples for counting specific types of characters and handling edge cases.

Beginner 📅 Jul 15, 2026 👁 52 views

Convert String to Uppercase and Lowercase in Java | Complete Guide

Learn how to convert strings to uppercase and lowercase in Java using toUpperCase() and toLowerCase() methods with code examples.

Beginner 📅 Jul 15, 2026 👁 76 views

Compare Strings in Java | Case Sensitive & Insensitive Methods Explained

Learn how to compare strings in Java with case sensitivity options. Includes equals(), compareTo(), and regionMatches() methods with code examples.

Beginner 📅 Jul 15, 2026 👁 64 views

Java Palindrome Check | 4 Methods with Code Examples & Best Practices

Learn 4 different methods to check if a string is a palindrome in Java. Includes code examples, best practices, and performance analysis for interviews.

Beginner 📅 Jul 15, 2026 👁 66 views

How to Reverse a String in Java | 5 Best Methods

Learn 5 different ways to reverse a string in Java with code examples, performance analysis, and detailed explanations for

Beginner 📅 Jul 15, 2026 👁 54 views

Find Missing Number in a Sequence in Java: 4 Methods (2026)

Learn how to find a missing number in a sequence in Java using the sum formula, XOR, and HashSet, plus how to find multiple missing numbers, with FAQs.

Beginner 📅 Jul 15, 2026 👁 54 views

Find Duplicate Numbers in an Array in Java: 4 Methods (2026)

Learn how to find duplicate numbers in a Java array using brute force, sorting, HashSet, and Streams, with time complexity comparisons and FAQs.

Beginner 📅 Jul 15, 2026 👁 48 views

Sum of Numeric Digits in a String in Java: Full Guide (2026)

Learn how to sum numeric digits in a Java string — both individual digit characters and complete embedded numbers — with full code and FAQs.

Beginner 📅 Jul 15, 2026 👁 69 views

Compare Two Numeric Values From Strings in Java (2026)

Learn why comparing numbers as strings in Java produces wrong results, and how to correctly compare numeric string values by parsing them first, with FAQs

Beginner 📅 Jul 15, 2026 👁 92 views

Generate Random Number in Java: Random, Math.random & More

Learn how to generate random numbers in Java using Math.random, java.util.Random, ThreadLocalRandom, and SecureRandom, with ranges, seeds, and FAQs.

Beginner 📅 Jul 15, 2026 👁 62 views

Validate Number in Range in Java: Inclusive vs Exclusive (2026)

Learn how to validate whether a number falls within a range in Java, covering inclusive vs exclusive boundaries, user input, and common off-by-one bugs.

Beginner 📅 Jul 15, 2026 👁 57 views

Extract Numeric Part From a String in Java: 4 Methods (2026)

Learn how to extract numeric parts from alphanumeric strings in Java using regex, StringBuilder, and replaceAll, with practical examples and FAQs.

Beginner 📅 Jul 15, 2026 👁 48 views

Count Numeric Values in a String in Java: Full Guide (2026)

Learn how to count numeric values (not just digit characters) in a Java string using regex Matcher and manual parsing, with full code and FAQs.

Beginner 📅 Jul 15, 2026 👁 47 views

Count Digits, Letters, Spaces & Special Chars in Java (2026)

Learn how to count digits, letters, spaces, and special characters in a string using Java's Character class methods, with full code and FAQs.

Beginner 📅 Jul 15, 2026 👁 54 views

Check If a Number Is Binary or Not in Java (2026 Guide)

Learn how to check if a number is binary in Java using a while loop and regular expressions, covering both int and String inputs, with FAQs.

Beginner 📅 Jul 15, 2026 👁 39 views

Check Buzz Number in Java: Divisibility + Last Digit (2026)

Learn how to check Buzz numbers in Java by testing divisibility by 7 or a last digit of 7, with full code, examples, and interview FAQs.

Beginner 📅 Jul 15, 2026 👁 52 views

Check Magic Number in Java: Digit Sum Reduction (2026)

Learn how to check magic numbers in Java by repeatedly summing digits until reaching a single digit and checking if it equals 1, with FAQs.

Beginner 📅 Jul 15, 2026 👁 48 views

Check Automorphic Number in Java: Logic + Full Code (2026)

Learn how to check automorphic numbers in Java by verifying if a number's square ends with the number itself, with numeric and String methods, plus FAQs.

Beginner 📅 Jul 15, 2026 👁 52 views

Check Spy Number in Java: Sum vs Product of Digits (2026)

Learn how to check spy numbers in Java by comparing the sum and product of digits, with full code, examples, and interview FAQs.

Beginner 📅 Jul 15, 2026 👁 46 views

Check Harshad Number in Java: Logic + Full Code (2026)

Learn how to check Harshad (Niven) numbers in Java by testing divisibility by the digit sum, with full code, examples, and interview FAQs.

View all 123 Code Snippets articles on one page →