Language
Version: SE 8
Categories
-
User Program Communication
-
Variables
-
Control Flow
-
Object Oriented Programming
-
String Class
String Class
String Variables in Java
String variables are variables used to hold strings.
Syntax
modifier String stringName = "String to store";
Notes
A string is technically an object, so its contents cannot be changed (immutable). For mutable strings, use the StringBuffer or StringBuilder classes.
A string variable must be initialized with either a value (which will be permanent) or null (for later initialization).
Example
String name = "Anthony";
System.out.println("Hello, your name is " + name);