Explain the process of declaring a String in Java.
Advertisements
प्रश्न
Explain the process of declaring 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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
