HOME > System software > Java: An Introduction To Strings - The Most Important Information

Java: An introduction to Strings - the most important information

If you use Java for programming, you will also work with string variables. Strings belong to the data types in Java and consist of a string of characters that can contain letters, digits, but also entire sentences. We give you an introduction to the use of strings here.

An introduction to strings: how to generate new string variables in Java

String variables, like int, double, and boolean, are among the data types in Java. However, strings are not a simple data type, but a class that does not contain the string itself, but only a reference to it. To generate a new string, you must first declare the variable with "String name" before you can assign it a range of values with "name=".

You can use these string functions in Java

Once you have generated a string variable, you can use various functions to further manipulate or analyze it. Besides the possibility to split a string into single arrays using the split function, you can also concatenate multiple string variables by using the "+" operator.
  1. To compare two strings with each other and check for equality or inequality, you need the "boolean equals (String s)" command.
  2. The length of the string, which results from the number of individual characters, you get again by entering "int length ()".
  3. Finally, you can also output only a subset of a string in Java by executing the command "String substring(int i, int j)". You must replace the placeholders "i" and "j" thereby by the start position of the substring as well as by the first position of the string, which no longer belongs to the substring.

By Frangos

FIFA 20: Release and more info about the soccer hit :: YouTube Premium Costs: What to Expect
USEFUL LINKS