- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Java Program to check whether it is possible to make a divisible by 3 number using all digits in an array

To check whether it is possible to make a divisible by 3 number using all digits in an array, the Java code is as follows −

## Example

import java.io.*; import java.util.*; public class Demo{ public static boolean division_possible(int my_arr[], int n_val){ int rem = 0; for (int i = 0; i < n_val; i++) rem = (rem + my_arr[i]) % 3; return (rem == 0); } public static void main(String[] args){ int my_arr[] = { 66, 90, 87, 33, 123}; int n_val = 3; if (division_possible(my_arr, n_val)) System.out.println("It is possible to make a number that can be divided by 3"); else System.out.println("It is not possible to make a number that can be divided by 3"); } }

## Output

It is possible to make a number that can be divided by 3

A class named Demo contains a function named ‘divide_possible’. It checks to see if the numbers can be used to make a number that can be divided by 3. In the main function, an array with values, and an ‘n’ value is defined. The function is called with the specific arguments and the relevant message will be displayed on the console.

- Related Questions & Answers
- Python Program to check whether it is possible to make a divisible by 3 number using all digits in an array
- C/C++ Program to check whether it is possible to make a divisible by 3 number using all digits in an array?
- C/C++ Program to check whether it is possible to make the divisible by 3 number using all digits in an array?
- Possible to make a divisible by 3 number using all digits in an array in C++
- Number of digits to be removed to make a number divisible by 3 in C++
- Java Program to check if all digits of a number divide it
- C Program to check if a number is divisible by sum of its digits
- C Program to check if a number is divisible by any of its digits
- Check whether it is possible to make both arrays equal by modifying a single element in Python
- Check if a large number is divisible by 3 or not in java
- C Program to Check if all digits of a number divide it
- PHP program to check if all digits of a number divide it
- Check whether product of digits at even places of a number is divisible by K in Python
- Check whether sum of digits at odd places of a number is divisible by K in Python
- C# Program to find whether the Number is Divisible by 2

Advertisements