Page 337 - CA_Blue( J )_Class10
P. 337

7          char ch;
                   8          int i,n, cl=0,cd=0;

                   9          System.out.print("Enter number of characters: ");
                  10          n = sc.nextInt();

                  11          for(i=1;i<=n;i++)
                  12          {

                  13              System.out.print("Enter a character :");
                  14              ch=sc.next().charAt(0);

                  15              if(Character.isLetter(ch))
                  16                    cl++;

                  17              if(Character.isDigit(ch))
                  18                    cd++;
                  19          }

                  20          System.out.println( "Number of Letters : "+ cl);

                  21          System.out.println( "Number of Digits : "+ cd);
                  22      }
                  23  }




                                Let's Revisit



                       ®  A package is a collection of similar types of classes and sub packages.

                       ®  Primitive data types are in-built data types developed by the developer of the language.
                       ®  Composite data types are those data types that are defined by the user using the primitive data types.
                       ®  A class may be considered as a new data type created by the user that has its own functionality.
                       ®  Wrapper classes are the in-built classes of Java that contain primitive data types.

                       ®  Automatic conversion from primitive data type to its corresponding object class is called autoboxing.
                       ®  Automatic conversion from object of wrapper class to its primitive data type is called unboxing.






















                                                                                                                       335
                                                                                                        Library Classes    335
   332   333   334   335   336   337   338   339   340   341   342