Wednesday, 28 December 2016

String in java

Strings are generally sequence of characters.

Java treats String as an Object.

Java has a class named String which has numerous methods using which one can perform various operation on String object. The String class is in java.lang package.

String class implements

·         Serializable interface
·         Comparable interface
·         CharSequence interface.

Create String Object

In java, String object can be created in the following two ways:

1.      String literal
String s = “Java”;

2.      By using new keyword
String s = new String(“Java”);

Most important characteristics of java String is immutability. String is immutable in java.

No comments:

Post a Comment

If you are looking for a reference book on java then we recommend you to go for → Java The Complete Reference
Click on the image link below to get it now.