Skip to Content

Find minimum of two numbers using Math.min

  • 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.   Find minimum of two numbers using Math.min
  3.   This java example shows how to find minimum of two int, float,
  4.   double or long numbers using min method of Java Math class.
  5. */
  6.  
  7. public class FindMinimumOfTwoNumbersExample {
  8.  
  9.   public static void main(String[] args) {
  10.    
  11.     /*
  12.      * To find minimum of two int values, use
  13.      * static int min(int a, int b) method of Math class.
  14.      */
  15.    
  16.     System.out.println(Math.min(34,45));
  17.    
  18.     /*
  19.      * To find minimum of two float values, use
  20.      * static float min(float f1, float f2) method of Math class.
  21.      */
  22.      System.out.println(Math.min(43.34f, 23.34f));
  23.  
  24.     /*
  25.      * To find minimum of two double values, use
  26.      * static double min(double d2, double d2) method of Math class.
  27.      */
  28.      System.out.println(Math.min(4324.334, 3987.342));
  29.    
  30.     /*
  31.      * To find minimum of two long values, use
  32.      * static long min(long l1, long l2) method of Math class.
  33.      */
  34.                
  35.      System.out.println(Math.min(48092840,4230843));
  36.   }
  37. }
  38.  
  39. /*
  40. Output would be
  41. 34
  42. 23.34
  43. 3987.342
  44. 4230843
  45. */