Strings can't be compared with with the equals operator - ==
. For strings, there exists a separate equals
-command, which is always appended to the end of the string that we want to compare.
When comparing strings, you should make sure the string variable has some value assigned to it. If it doesn't have a value, the program will produce a NullPointerException error, which means that no value has been assigned to the variable, or that it is empty (null).
You can split a string to multiple pieces with the split
-method of the String class. The method takes as a parameter a string denoting the place around which the string should be split. The split
method returns an array of the resulting sub-parts.
Strings have a contains
-method, which tells if a string contains another string.
You can get a character at a specified index of a string with the charAt
method
You can find out the length of a string with length()
-method