Skip to Content

Convert Byte to numeric primitive data types example

  • strict warning: Non-static method view::load() should not be called statically in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/views.module on line 906.
  • strict warning: Declaration of views_handler_argument::init() should be compatible with views_handler::init(&$view, $options) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_argument.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter_boolean_operator::value_validate() should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/handlers/views_handler_filter_boolean_operator.inc on line 0.
  • strict warning: Declaration of views_plugin_style_default::options() should be compatible with views_object::options() in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_style_default.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/javaexa1/public_html/sites/all/modules/views-6.x-2.16/views/plugins/views_plugin_row.inc on line 0.

  1. /*
  2.   Convert Byte to numeric primitive data types example
  3.   This example shows how a Byte object can be converted into below given numeric
  4.   data types
  5.   - Convert Byte to byte
  6.   - Convert Byte to short
  7.   - Convert Byte to int
  8.   - Convert Byte to float
  9.   - Convert Byte to double
  10.   - Convert Byte to long
  11. */
  12.  
  13. public class ByteToNumericPrimitiveTypesExample {
  14.  
  15.   public static void main(String[] args) {
  16.     Byte bObj = new Byte("10");
  17.     //use byteValue method of Byte class to convert it into byte type.
  18.     byte b = bObj.byteValue();
  19.     System.out.println(b);
  20.    
  21.     //use shortValue method of Byte class to convert it into short type.
  22.     short s = bObj.shortValue();
  23.     System.out.println(s);
  24.    
  25.     //use intValue method of Byte class to convert it into int type.
  26.     int i = bObj.intValue();
  27.     System.out.println(i);
  28.    
  29.     //use floatValue method of Byte class to convert it into float type.
  30.     float f = bObj.floatValue();
  31.     System.out.println(f);
  32.  
  33.     //use doubleValue method of Byte class to convert it into double type.
  34.     double d = bObj.doubleValue();
  35.     System.out.println(d);
  36.    
  37.     //use longValue method of Byte class to convert it into long type.
  38.     long l = bObj.longValue();
  39.     System.out.println(l);
  40.    
  41.    
  42.   }
  43. }
  44.  
  45. /*
  46. Output of the program would be :
  47. 10
  48. 10
  49. 10
  50. 10.0
  51. 10.0
  52. 10
  53. */