Wednesday, May 30, 2018

String Literals using JAVA

String literals in Java are specified like they are in most other languages—by enclosing
a sequence of characters between a pair of double quotes. Examples of string literals are
“Hello World”
“two\nlines”
“\”This is in quotes\””
The escape sequences and octal/hexadecimal notations that were defined for
character literals work the same way inside of string literals. One important thing to
note about Java strings is that they must begin and end on the same line. There is no
line-continuation escape sequence as there is in other languages.
As you may know, in some other languages, including C/C++, strings are implemented
as arrays of characters. However, this is not the case in Java. Strings are actually object
types. As you will see later in this book, because Java implements strings as objects, Java
includes extensive string-handling capabilities that are both powerful and easy to use.
banner
Previous Post
Next Post

0 comments: