Strings
Java has the string data type, which is used to represent a sequence of characters. String is one of the fundamental data types in Java and you will encounter it in almost all programs.
A string is simply a sequence of characters. "Hello World", "London", and "Toyota" are all examples of strings in Java. Strings are objects in Java and not primitive types. They are immutable, that is, once they are created, they cannot be modified. Therefore, the methods we will consider in the following sections only create new string objects that contain the result of the operation but don't modify the original string object.
Creating a String
We use double quotes to denote a string, compared to single quotes for a char:
public class StringsDemo { public static void main(String[] args) { String hello="Hello World"; System.out.println(hello); } }
The output is as follows:
The hello object is now a string and is immutable. We can use delimiters...