Page 435 - CA_Blue( J )_Class10
P. 435

22              }
                  23              break;

                  24           case 2:
                  25              for(i=l-1;i>=0;i--)

                  26              {
                  27                  extwd="";

                  28                  for(j=i;j<l;j++)
                  29                  {

                  30                      extwd=extwd+wd.charAt(j);
                  31                  }

                  32                  System.out.println(extwd);
                  33              }
                  34              break;

                  35              default: System.out.println("Wrong choice");

                  36          }
                  37      }
                  38  }




                                Let’s Revisit


                      ®  A string is a sequence of characters enclosed between double quotes.
                      ®  The String class is available under the java.lang package of Java Class Library (JCL).
                      ®  The length() method is used to return the number of characters present in the string.
                      ®  The charAt() method returns the character in the given index.
                      ®  The indexOf() method returns the index of the first occurrence of the character passed as parameter in the String object.
                      ®  The lastIndexOf() method returns the index of the last occurrence of the character passed as parameter in the current String object.
                      ®  The toLowerCase() method converts the String to small letters.
                      ®  The toUpperCase() method converts the String to capital letters.
                      ®  The concat() method combines two strings together.
                      ®  A substring is a sequence of characters that appears within a larger string.
                      ®  The substring() method is used for extracting all the characters from the index position till the end of the string.
                      ®  The replace () method replaces all the occurrences of a character in the string with the provided character.
                      ®  The equals() method checks whether the current String object whose method is called is same as the String value passed as
                       parameter.
                      ®  The equalsIgnoreCase() method is similar to the equals() method and also checks whether the string of the current String
                       object whose method is called is same as the string value passed as the parameter.
                      ®  The compareTo() method compares the given String in the parameter with current String object alphabetically.
                      ®  The startsWith() method checks whether the string in the current String object starts with the string in the parameter.
                      ®  The endsWith() method checks whether the string in the current String object is ending with the string in the parameter.
                      ®  The trim() method is used to delete the leading and trailing spaces from the current String object.
                      ®  The valueOf() method is used to convert any primitive value to string.
                      ®  An array of strings is known as String array.



                                                                                                                       433
                                                                                                       String Handling  433
   430   431   432   433   434   435   436   437   438   439   440