Character Extraction:
2)getChars()
If you want to extract more than one character at a time,you can use the getChars() method.
It has general form:
void getChars(int sourceStart,int sourceEnd,char target[],int targetStart);
package stringdemo;
public class NewClass {
public static void main(String[] args) {
String s="This is the demo of getChar()method";
int start=5;
int end=8;
char ch[]=new char[end-start];
s.getChars(start, end, ch, 0);
System.out.println(ch);
}
}
The output is:
is
Related Posts:
Recursion Function in java:Recursion Function in java:
public class Factorial {
//this is recursive function
int fact(int n){
int resu… Read More
java while loopjava while loop
package javaapplication27;
public class WhileloopDemo {
public static void main(String[] args) {
… Read More
Do-While loop:Do-While loop:
package javaapplication27;
public class DowhileLoop {
public static void main(String[] args) {
&nbs… Read More
Java twodimensional array:Java twodimensional array:
package javaapplication27;
public class TwoDArrayDemo {
public static void main(String[] args) {
&… Read More
Nested Loop:Nested Loop:
package javaapplication27;
public class NestedLoop {
public static void main(String[] args) {
&nbs… Read More
0 comments:
Post a Comment