Page 245 - Computer science 868 Class 12
P. 245

19                      }
                  20                      if(Character.isLowerCase(ch))

                  21                      {
                  22                          cs++;

                  23                      }
                  24                      if(Character.isDigit(ch))

                  25                      {
                  26                          cd++;
                  27                      }

                  28                  }

                  29                  System.out.println("Number of Capital Letters : "+cc);
                  30                  System.out.println("Number of Small Letters : "+cs);
                  31                  System.out.println("Number of Digits : "+cd);

                  32               }
                  33          }

                 The output of the preceding program is as follows:
                 Enter a sentence :

                 This is an ostrich egg.
                 Number of Small Letters : 1
                 Number of Small Letters : 17
                 Number of Digits : 0


                 8.10.1 Methods of Wrapper Class
                 These methods are used to convert Primitive data types to String and vice versa. The various methods under wrapper
                 class are as follows:
                   1. toString(argument): These methods are used to convert primitive data type to a String. Some of them are as
                    follows.
                   •  Integer.toString(): This method converts an integer to String type.
                      String str=Integer.toString(28);                      //Output: “28”

                        Note: After a number is converted to string, the value will not support any type of calculation.



                   •  Long.toString(): This method converts a long type to a String type.
                         String str=Long.toString(2875849);               //Output: “2875849”

                   •  Double.toString(): This method converts a double type to a String type.
                        String str=Double.toString(2564.568);             //Output: “2564.568”

                   •  Float.toString(): This method converts a float type to a String type.
                         String str=Float.toString(256.5);                //Output: “256.5”





                                                                                                                       243
                                                                                                            Methods    243
   240   241   242   243   244   245   246   247   248   249   250