
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Found 21 Articles for Java.Util Package

2K+ Views
Time formatting is a process of converting date and time values into human-readable strings with specific formats. The resulting string describes how date/time values should be represented (such as flat files or human-readable output). In this article, we will understand how to format time in AM-PM format. In 12-hour clock system, AM-PM format is used to define time. Here, AM stands for Ante meridiem which refers to the time before noon, whereas PM stands for Post meridiem which shows the time period after noon. Example Scenario Input: current_date = Thu Mar 17 16:04:31 IST 2024 Output: Current Time ... Read More

2K+ Views
We are given a Set that contains multiple elements and our task is to write a Java program to remove elements from the Set. Here, the Set is an Sub Interface of the Java Collection Interface which defines a mathematical set. Removing Set Elements in Java To remove elements from a given set in Java, use the following ways − Using clear() method Using removeAll() method Using Iterator and remove() Using Java clear() method With the help of clear() method, we can remove all elements ... Read More

215 Views
It is an algorithm to perform factorization on given integers. Following is the program implementing the Rho Algorithm for Prime Factorization.ProgramLive Demopublic class PollardsRho { int num = 65; public int gcd(int a, int b) { int gcd = 0; for(int i = 1; i

4K+ Views
Sieve of Eratosthenes is the ancient algorithm to find prime numbers up to a given number.Algorithm1. Generate integers from 2 to n (Given number).2. Counting from 2 mark every 2nd integer. (multiples of 2)3. Now, starting from 3 mark every third integer. (multiples of 3)4. Finally, marking from 5 mark every 5th integer.(multiples of 5)Programimport java.util.Scanner; public class SievePrimeFactors { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number"); int num = sc.nextInt(); boolean[] bool = new boolean[num]; ... Read More

487 Views
According to Euler’s criterion a square root of n under modulo p exists if and only if a number num exists such that num%p is equal to n%p.Programimport java.util.Scanner; public class EulersCriterion { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter n value :"); int n = sc.nextInt(); System.out.println("Enter p value :"); int p = sc.nextInt(); n = n % p; int flag = 0; for ... Read More

214 Views
You can calculate the exponent of the largest power of a PrimeNumber that divides the factorial n! using Legendre's formula.Programimport java.util.Scanner; public class LegendresFormula { static int Largestpower(int n, int p) { int ans = 0; while (n > 0) { n /= p; ans += n; } return ans; } public static void main (String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the n value :"); ... Read More

4K+ Views
Binomial coefficient (c(n, r) or nCr) is calculated using the formula n!/r!*(n-r)!. Following is the Java program find out the binomial coefficient of given integers.Programimport java.util.Scanner; public class BinomialCoefficient { public static long fact(int i) { if(i

117 Views
Following is a Java program which prints the multiplicative order of given numbers.import java.util.Scanner;Programpublic class MultiplicativeOrder { public static int gcd(int num1, int num2) { if (num2 != 0) { return gcd(num2, num1 % num2); } else { return num1; } } static int multiplicativeOrder(int num1, int num2) { if (gcd(num1, num2) != 1) { return -1; } int res = 1; int p ... Read More