Ch-10 Strings in Java
Ch-10 Strings in Java
Ch-10 Strings in Java
Strings in Java
A string is a sequence of one or more characters enclosed in double quotes. In Java, strings
are class objects instantiated using two classes defined in java.lang:
1. String
2. StringBuffer
Initialization:
1. Using a String literal:
String s = new String (“May”);
String s = “May”;
String x = new String(s); // creates String x from String s
Initialization:
Syntax: String array-name [ ] = { “String1”, “String2”,…,”StringN” };
String StringBuffer
Method Description
countTokens( ) Returns the number of tokens to be parsed, using the current set of delimiters.