getchars & valueof
1.
valueOf():
This method is used to convert the string into any other data type
The general form
is.
String valueOf(double)
String valueOf(int )
String valueOf(char [ ])
2.
getChars():
This method is
used to extract the specific group of characters from the string and assign it
into the character array.
The general form
is:
getChars(int sindex,int eindex,char
t[],int position)
Where:
sindex is the starting index position .
eindex is the ending index position. Actually the
string is extracted upto the position eindex-1.
t is the target character array.
position is used
to specify the index position from where the insertion will start in the target
array
char t[]=new char[50];
String s="computer";
s.getChars(3,6,t,0);
for(int i=0;i<s.length();i++)
System.out.print(t[i]);
Comments
Post a Comment