Page 332 - CA_Blue( J )_Class10
P. 332

•  Float.parseLong(String): The Float.parseLong(String) method is used to convert a string value into float type value.
                  It takes a string value as parameter and returns after converting it into float. It converts a string value into float if
                  and only if the passed value does not contain a letter or symbol. Syntax (any one of the following can be used) is:
                  Float variable = Float.parseLong(String);
                  Float variable = Float.valueOf(String);
                  Let us take an example:
                  String s= "345.56";
                  float fn;
                  fn=Float.parseFloat(s);  OR   fn=Float.valueOf(s);
                  System.out.println("Result: " + fn);
                  Output:
                  Result: 345.56
              •  Double.parseDouble(String): The Double.parseDouble(String) method is used to convert a string value into double
                  type value. It takes a string value as parameter and returns after converting it into double. It converts a string value
                  into double if and only if the passed value does not contain a letter or symbol. Syntax (any one of the following can
                  be used) is:

                  Double variable = Double.parseDouble(String);
                  Double variable = Double.valueOf(String);
                  Let us take an example:

                  String s= "345566789.78";
                  double dn;
                  dn=Double.parseDouble(s); OR   fn=Double.valueOf(s);
                  System.out.println("Result: " + fn);
                  Output:
                  Result: 345566789.78

              13.5.3 Different Methods of Character Wrapper Class
              The Character class wraps a value of the primitive type char in an object. When a single digit, letter or any symbol is
              enclosed between single quotes is known as character data type. For example,'a' ,'3','/', etc.

              Using the Scanner class, you can take the character type data as input in the following ways:
                  Scanner sc = new Scanner();
                  char ch1 = sc.next().charAt(0);
              OR

              Using the InputStreamReader and BufferedReader classes:

                  BufferedReader br = new BufferedReader(InputStreamReader);
                  char ch1=(char)(br.read());

              Methods of Character Class
              Some of the methods of the Character class to manipulate the character type data are:
              •  Character.isLetter(): This method is used to check whether the parameter passed is a character or not. It returns a
                  boolean value. Syntax of the isLetter() method is:

                  boolean variable=Character.isLetter(char);
                  For example:
                  boolean b=Character.isLetter('A');
                  Output: true                           // as'A' is a character

                  boolean b=Character.isLetter('1');
                  Output: false                          //as'1' is not a character





                330330  Touchpad Computer Applications-X
   327   328   329   330   331   332   333   334   335   336   337