O'Reilly logo

Java Quick Syntax Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5

image

String

The String class in Java is a data type that can hold string literals. String is a reference data type, as are all non-primitive data types. This means that the variable contains an address to an object in the memory, and not the object itself. A String object is created in the memory, and the address to the object is returned to the variable.

As seen below, string literals are delimited by double quotes. This is actually a shorthand notation for the regular reference type initialization (creation) syntax, which uses the new keyword.

String a = "Hello";String b = new String(" World");

Combining strings

The plus sign is used ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required