String class methods:
1. charAt():
This method is used to extract
the character from a particular index position.
E.g:
String s=new String(“computer”);
System.out.println(s.charAt(2));
Output:
m
2.
length():
This method is
used to return the length of the string . That is , the total number of
characters present in it .
The general form is,
length()
E.g.
String
s=new String("computer");
System.out.println("length="+s.length());
Output:
Length=8
Comments
Post a Comment