Find ceiling value of a number using Math.ceil - Java Language Basics

Java examples for Language Basics:Math

Introduction

Math.ceil method returns the smallest interger which is not less than the value.

Demo Code

 
public class Main {
 
  public static void main(String[] args) {
    System.out.println(Math.ceil(101));

    System.out.println(Math.ceil(101.1));
   //from  w  ww. j a  v  a 2 s  .c om
    System.out.println(Math.ceil(5.5));
   
    System.out.println(Math.ceil(-20));
   
    System.out.println(Math.ceil(-421.4));
   
    System.out.println(Math.ceil(0));
   
  }
}

Result


Related Tutorials