Java Blog

 
 
 
 public class JAVA_052
 {
    public static void main(String[] args)
    {
       String Text=\"To be or not to be\";

       System.out.println(\"The String is : \" + Text + \"\\n\");

       int count=0;
       int index=0;

       char Separator=\' \';

       do
       {
          ++count;
          ++index;

          index=Text.indexOf(Separator,index);
       }
       while(index!=-1);

       String[] subStr=new String[count];

       int endIndex=0;

       index=0;

       for(int i=0;i<count;i++)
       {
          endIndex=Text.indexOf(Separator,index);

          if(endIndex==-1)
             subStr[i]=Text.substring(index);

          else
             subStr[i]=Text.substring(index,endIndex);

          index=(endIndex+1);
       }

       System.out.println(\"The extracted subStrings are :\");

       for(int j=0;j<count;j++)
          System.out.println(subStr[j]);
    }
 }

    Related Post:
  1. Program that enabled applet calculator

  2. Program to show the use of Bitwise Operator (&) AND

  3. Program for Thread Priority

  4. Program of inventory management and demonstrating interactive input and output

  5. Program to show an example of Concatination of Strings

  6. Program to show the use of Conditional OR Operator (||) in If Statements

  7. Program to calculate the frequency for different values of C starting from 0.01 to 0.1 in steps of 0.01

  8. Word list program that reads a text file and makes an alphabetical list of all the words in that file. The list of words is output to another file

  9. Program to show an example of getting at characters in a String

  10. Program which will read a string and rewrite it in the alphabetical order

  11. Servlet which takes input from an HTML client page and calculates and outputs the premium amount

  12. Program of concatenating and Buffering files

  13. Even number ,Prime no. ,Factorial of a number

  14. RMI application for getting the final total price of the shopping list with some of the following items and quantities chosen by the user

  15. Program to evaluate following investment equation V=P(1+R)^N

  16. Program of UDP datagram

  17. Program which calls the method sort(int []a) which throws the Exception ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

  18. Program to show insertion of StringBuffer, String objects and other Basic Data Types into a StringBuffer object

  19. Program to show an example of using constructors in a class to initialize its data members

  20. Program to declare and initialize Boolean variables and print them on the Standard Output Device

 
 
Didn't find what you were looking for? Find more on Program to show an example of extracting subStrings from a String