×

Java Integer divideUnsigned() method

The divideUnsigned() method of Integer class returns the unsigned quotient by dividing the first argument by the second argument.

Syntax

public static int divideUnsigned (int dividend , int divisor)

Parameters

The parameter ‘dividend’ represents the value to be divided and ‘divisor’ represents the second value to divide.

Return Value

This method returns the unsigned quotient.

Example 1

public class JavaIntegerDivideUnsignedExample1 {
    public static void main(String[] args) {
        int dividend=56;
        int divisor=8;
        // returns the quotient after dividing dividend and quotient
        int quotient=Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+"="+quotient);
    }
}

Output

56/8=7

Example 2

public class JavaIntegerDivideUnsignedExample2 {
    public static void main(String[] args) {
        int dividend=56;
        int divisor=0;
        // returns an arithmetic exception when divisor is 0
        int quotient=Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+"="+quotient);
    }
}

Output

Exception in thread "main" java.lang.ArithmeticException: / by zero
            at java.lang.Integer.divideUnsigned(Integer.java:1294)
            at com.TutorialAndExample.JavaIntegerDivideUnsignedExample2.main(JavaIntegerDivideUnsignedExample2.java:8)


Example 3

public class JavaIntegerDivideUnsignedExample3 {
    public static void main(String[] args) {
        int dividend=Integer.MAX_VALUE;
        int divisor=Integer.MIN_VALUE;
        // returns 0 when max value is divided by min value
        int quotient=Integer.divideUnsigned(dividend,divisor);
        System.out.println(dividend+"/"+divisor+"="+quotient);
    }
}

Output

2147483647/-2147483648=0

Related Topics

Difference Between in Java and C++

FeatureC++JavaDefinitionC++ is a general programming language created by Bjarne Stroustrup as an extension of c language    Java is class-based, object-based, and designed to have as few implementation dependencies as...

4 minutes read.

Sorting a String in Java

Sorting a String in Java Sorting is a process of arranging available data objects in a meaningful format that is ascending or descending order. Sorting a string or array of String...

4 minutes read.

Replace character in string Java

Characters in Java In the package of Java language, there is a container class called Character. A single field of type char is contained in a Character object. For manipulating characters,...

4 minutes read.

Types of JDBC Drivers

JDBC Drivers: A piece of software known as JDBC Driver permits database communication between Java applications and the server. In order to communicate with our database server, JDBC drivers put into practice...

4 minutes read.

Polymorphism Program in Java

Polymorphism Program in Java: Polymorphism means the existence of different forms of an object. The object can be a class object or a real-time entity. For example, a person can...

5 minutes read.

Java Math log() Method

The log() method of Math class returns the natural logarithmic value for the specified double argument. Syntax: public static double log(double a) Parameters: The parameter ‘a’ represents the value. Return Value: The log() method returns the...

1 minute read.

Java Control Statements

Control Statements: Control statements in Java can also be referred to as decision-making while dealing with different problems. Control statements are helpful to sort out the flow of the program or...

7 minutes read.

Object Oriented Programming (OOPs)

Since the dawn of earth, we have kept on evolving. The need for evaluation comes with the aim of improving the existing systems when something inappropriate is found for the...

5 minutes read.

Java Math addExact() Method

The addExact() method of Math class returns the sum of the two arguments, throwing an exception if the result overflows a long or an int. Syntax public static int addExact (int x,...

1 minute read.

PriorityBlockingQueue Class in Java

What is the Queue? An abstract data structure like Stacks is a queue. A queue is open on both ends. Data is always pushed to one end, called enqueue, and removed...

4 minutes read.

Comparator vs Comparable in Java

Comparator Vs Comparable in Java In Java, sorting of primitive data types can be done using different inbuilt functions that are available. But for sorting the collection of objects or types...

4 minutes read.

Java Set to List

In this article, you will be acknowledged about how the process of conversion from Set or HashSet to LinkedList happens and what are the possible ways involved in conversion process. First...

4 minutes read.

Generic queue in Java

Before understanding how to implement a generic queue in java, one must know about generics and queue in java. Generics in Java Generics are parameterized types. The goal is to enable type...

6 minutes read.

Java exception list

Java uses exceptions, like the majority of contemporary programming languages, to deal with both errors and "extraordinary events." When an exception arises inside the program, it messes up the regular...

6 minutes read.

Java Garbage Collection

Java Garbage Collection In Java, unreferenced objects are treated like garbage. The process of reclaiming the unused memory during runtime automatically is known as the Java Garbage Collection.In other words, the...

4 minutes read.

Java Binary Tree

The non-linear data structure known as a binary tree is a type of tree, and because it stores data in a hierarchical manner, it is mostly utilised for finding and...

7 minutes read.

Getting the Day from the Date in Java?

To extract the day's name from the date, we will write Java application. When dealing the date and time in Java, the following classes are used. Class for Calendars: This class is...

6 minutes read.

Get yesterdays date by no of days in Java

In this tutorial, we are going to learn how to get yesterday’s date by the no of days in Java. Using the Calendar class, one can get the current date....

1 minute read.

Crown Pattern in Java

We know the importance of solving pattern problems. We can solve pattern problems by using any programming language. There is no rule to translating into a particular programming language. We...

4 minutes read.

Longest Odd Even Subsequence in Java

In order to solve the Java problem known as the longest odd-even subsequence, one must identify a sequences in a non-negative array having size s that alternately includes odd and...

6 minutes read.