String is the most important part of Java language.The Communication in Java is provided by Strings.String provides a wide range of functions,each having its own task,below are the most commonly used String functions:
1. CharAt(): This function extracts a single character from a string.This method checks the value of the given position which is specified as argument.
Syntax: Stringname.CharAt(Value);
2.getChars():This function can be called as an advanced version of CharAt(),because it displays more than one character you want to display.
Syntax: getChars(int source start,int source end,char target array[],int target start)
For your clarity of the concepts,we had used small programs in which the above functions are covered.
//For charAt() and getChars()
class Sort{
public static void main(String arg[])
{
String k="Koding Point";
char[] ch= new char[10];
System.out.println(k.charAt(7));
k.getChars(2,10,ch,0);
System.out.println(ch);
}
}
The output is:
1. CharAt(): This function extracts a single character from a string.This method checks the value of the given position which is specified as argument.
Syntax: Stringname.CharAt(Value);
2.getChars():This function can be called as an advanced version of CharAt(),because it displays more than one character you want to display.
Syntax: getChars(int source start,int source end,char target array[],int target start)
For your clarity of the concepts,we had used small programs in which the above functions are covered.
//For charAt() and getChars()
class Sort{
public static void main(String arg[])
{
String k="Koding Point";
char[] ch= new char[10];
System.out.println(k.charAt(7));
k.getChars(2,10,ch,0);
System.out.println(ch);
}
}
The output is:
0 comments: