Jun 5, 2024
String name = "Naveen";
new
Keyword
String name = new String("Naveen");
name
.String
in Java is a class, not a primitive type.
String
.String name = "Naveen";
and String name = new String("Naveen");
are valid.+
Operator.
String fullName = "Hello" + name;
results in Hello Naveen
.charAt
Method.
name.charAt(1)
returns a
from Naveen
.equals
Method.
name.equals(anotherName)
to compare two strings.hashCode
Method.
System.out.println("Hello " + name);
System.out.println(name.charAt(1)); // prints 'a'
String fullName = name + " Reddy";
System.out.println(fullName); // prints 'Naveen Reddy'
String name = "value";
over new String("value");