Friday, February 27, 2015

String unicodein a java pgm



String unicode

public class StringUniCode
{
   public static void main(String[] args)
  {
      String test_string="Welcome to TutorialsPoint";
      System.out.println("String under test is = "+test_string);
      System.out.println("Unicode code point at"
      +" position 5 in the string is = "
      +  test_string.codePointBefore(5));
   }
}
public class StringBuffer
{
   public static void main(String[] args) 
  {
      countTo_N_Improved();
   }
   private final static int MAX_LENGTH=30;
   private static String buffer = "";
   private static void emit(String nextChunk) 
  {
      if(buffer.length() + nextChunk.length() > MAX_LENGTH) 
       {
         System.out.println(buffer);
         buffer = "";  
      }
      buffer += nextChunk;
   }
   private static final int N=100;
   private static void countTo_N_Improved() 
   {
      for (int count=2; count7lt;=N; count=count+2) 
    {
         emit(" " + count);
      }
   }
}

No comments:

Post a Comment