how character and string are declared java. explain with syntax?
Answers
Answered by
19
There are two ways to create a String object:
By string literal : Java String literal is created by using double quotes. For Example: String s=“Welcome”;
By new keyword : Java String is created by using a keyword “new”. For example: String s=new String(“Welcome”);
Answered by
8
The strings in java are a collection of characters bound by double quotes(“”). They are immutable, i.e once they are declared, their values cannot be changed.String can also be listed as an array of characters starting at the index 0 and ending with a null character (\0)
Similar questions