Explain the process of Initializing a String in Java.
Advertisements
प्रश्न
Explain the process of Initializing a String in Java.
स्पष्ट करा
Advertisements
उत्तर
In Java, String declaration is the process of declaring a reference variable of the String class. A String is declared by writing the class name String followed by a valid variable name and a semicolon. This declaration creates a reference variable that can refer to a String object, but no String value is assigned at this stage.
- Write the class name
String. - Specify a valid variable name.
- End the declaration with a semicolon (
;).
Syntax:
String variableName;Example:
String name; In the above example,
String is the class name, and name is the reference variable declared to refer to a String object.shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
