Friday, 14 June 2013

string operations

1-Suppose you dont want to print whole of the string but a specified portion of it
THEN do as follows
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[

class nn{
   public static void main(String args[]){
      String a = ("Welcome to specbug.blogspot.com");

     
      System.out.println(a.substring(10) );// prints letter after 10th position ie specbug.blogspot.com
     
   }
}

]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
2-if you want a particular area to be displayed ie a particular region then follow
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
import java.io.*;

class Test{
    static void main(String args[]){
      String Str1 = new String("Welcome to specbug.blogspot.com");//target start
      char[] Str2 = new char[9];//character array

      try{
         Str1.getChars(2, 9, Str2, 0);//String.getChars(start,end,character array,target start)
       
         System.out.println(Str2 );//prints characters b/w 2nd and 9th position

      }catch( Exception ex){
       
      }
   }
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

No comments:

Post a Comment