O'Reilly logo

Sun Certification Training Guide (310-025, 310-027): Java™ 2 Programmer and Developer Exams by Jamie Jaworski

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

The String and StringBuffer Classes

The String and StringBuffer classes are used to support operations on strings of characters. The String class supports constant (unchanging or immutable) strings, whereas the StringBuffer class supports expandable, modifiable strings. String objects are more compact than StringBuffer objects, but StringBuffer objects are more flexible.

String Literals

String literals are strings that are specified using double quotes. "This is a string" and "xyz" are examples of string literals. String literals are different from the literal values used with primitive types.

When the javac compiler encounters a String literal, it converts it to a String constructor. For example, the following:

String str = "text";

is equivalent ...

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