-
Book Overview & Buying
-
Table Of Contents
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
By :
The String class is such a fundamental class that you'd be hard-pressed to write code without it. After all, you can't even write a main() method without using the String class. A string is basically a sequence of characters; here's an example:
String name = "Fluffy";
As you learned in Chapter 1, “Java Building Blocks,” this is an example of a reference type. You also learned that reference types are created using the new keyword. Wait a minute. Something is missing from the previous example: it doesn't have new in it! In Java, these two snippets both create a String:
String name = "Fluffy";
String name = new String("Fluffy");
Both give you a reference variable of type name pointing to the String object "Fluffy". They are subtly different, as you'll see in the section “String Pool,” later in this chapter. For now, just remember that the String class is special...
Change the font size
Change margin width
Change background colour