Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / Knowledge base

Knowledge base

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 5788

Java

String.contains — checking for a substring

String.contains checks whether text contains a given sequence of char values. It returns boolean, is case-sensitive, and does not interpret regular expressions.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

The String(String) copy constructor

The `String(String)` constructor creates a distinct object with the same text. Use `==` to compare references and `equals` to compare string contents.

Advanced · Java SE 21
Java

String.equals — comparing string contents

String.equals compares string contents with case sensitivity. The == operator compares object identity rather than contents.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.format — formatting text

String.format builds text from a format string and arguments using specifiers such as %s, %d, and %.2f. An explicit Locale makes numeric formatting independent of the environment's default locale settings.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.hashCode — a string's hash code

String.hashCode returns an int hash code calculated from a string's contents. Equal strings have equal hashes, but matching hashes do not prove that strings are equal.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.indexOf — finding a substring

String.indexOf returns the position of the first substring match or -1. The fromIndex parameter lets you start searching at a specified position.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.isBlank — checking empty or whitespace-only text

String.isBlank checks whether a string is empty or contains only whitespace as defined by Character.isWhitespace(int). It returns boolean and has been available since Java 11.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.isEmpty — checking for an empty string

String.isEmpty() checks whether a string has length zero. It does not treat spaces as empty text and requires a non-null reference; use isBlank() to check for empty text or text consisting only of whitespace.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.join — joining text with a delimiter

String.join builds text from elements separated by a delimiter. It accepts an Iterable or varargs arguments.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.length — length in UTF-16 units

String.length() returns the number of UTF-16 code units, not necessarily the number of user-visible characters.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.matches: match an entire string against a regex

Test whether an entire string matches a regular expression. Learn how `(?s)` changes the dot, which character classes default to ASCII, and how to write regex backslashes in Java string literals.

Intermediate · Java SE 21
Java

String.replace — literal text replacement

String.replace replaces all literal matches without regular expressions. It returns the result without changing the original.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

`String.replaceAll()`: regex replacement

Replace every match of a regular expression. The example masks values in one specific password-argument format without changing the inputs.

Advanced · Java SE 21
Java

String.split — splitting text with a regular expression

String.split returns an array of text fragments separated by regular-expression matches. The limit parameter controls the number of splits and the treatment of trailing empty elements.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.startsWith — checking a prefix

String.startsWith checks whether a string begins with a given prefix, optionally at a specified index.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.substring — extracting part of a string

String.substring returns part of a string without changing the original. The start is inclusive and the end exclusive; indices count UTF-16 code units.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.toLowerCase — converting to lowercase

String.toLowerCase returns lowercase text. The choice of Locale affects the result; use Locale.ROOT for language-independent text.

Basic · Java SE 21; repository runtime, production runtime not attested
Java

String.toUpperCase — converting to uppercase

String.toUpperCase returns uppercase text. The chosen Locale affects the result; Locale.ROOT provides language-neutral rules.

Basic · Java SE 21; repository runtime, production runtime not attested