Page 350 - Computer science 868 Class 12
P. 350

Output:
                  The index value is: 0
                4. int indexOf(char ch, int index): This method returns the index value of the character ch present in the string of the
                  current String object starting from the index provided in the parameter. It returns integer type of value.
                  Syntax: int <variable> = Stringobject.indexOf(char ch, int index);
                  Example:
                      String str = "Computer Science – Class XII";
                      int n = str.indexOf('C',15);
                      System.out.println("The index value is :" +n);
                  Output:
                  The index value is: 19

                5. int lastIndexOf(char ch): This method returns the index value of the last existing of the character ch present in the
                  string of the current String object. It returns integer type of value.

                  Syntax: int <variable> = Stringobject.lastIndexOf(char ch);
                  Example:
                      String str = "Computer Science – Class XII";
                      int v = str.lastIndexOf('s');
                      System.out.println("The index value is :" +v);
                  Output:
                  The index value is: 24
                6. String toLowerCase(): This method converts the string of the current Stringobject to small letters. It returns a
                  String.

                      Note:  If the Stringobject contains any small letters or digits or special characters, then there will be no
                      change.


                  Syntax: String <variable> = Stringobject.toLowerCase();
                  Example:
                      String str = "Computer Science – Class XII";
                      String changestr = str.toLowerCase();
                      System.out.println("The converted string is :" +changestr);
                  Output:
                  The converted string is: computer science – class xii
                7. String toUpperCase(): This method converts the string of the current Stringobject to capital letters. It returns a
                  String.


                      Note:  If the string contains any capital letters or digits or special characters, then there will be no change.



                  Syntax: String <variable> = Stringobject.toUpperCase();
                  Example:
                      String str = "Computer Science – Class XII";
                      String changestr = str.toUpperCase();
                      System.out.println("The converted string is :" +changestr);
                  Output:
                  The converted string is : COMPUTER SCIENCE – CLASS XII


                348348  Touchpad Computer Science-XII
   345   346   347   348   349   350   351   352   353   354   355