
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 7442 Articles for Java

13K+ Views
Generate temporary password is now a requirement on almost every website now-a-days. In case a user forgets the password, system generates a random password adhering to password policy of the company. Following example generates a random password adhering to following conditions −It should contain at least one capital case letter.It should contain at least one lower-case letter.It should contain at least one number.Length should be 8 characters.It should contain one of the following special characters: @, $, #, !.Exampleimport java.util.Random; public class Tester{ public static void main(String[] args) { System.out.println(generatePassword(8)); } private ... Read More

13K+ Views
Generate temporary password is now a requirement on almost every website now-a-days. In case a user forgets the password, system generates a random password adhering to password policy of the company. Following example generates a random password adhering to following conditions −It should contain at least one capital case letter.It should contain at least one lower-case letter.It should contain at least one number.Length should be 8 characters.It should contain one of the following special characters: @, $, #, !.Exampleimport java.util.Random; public class Tester{ public static void main(String[] args) { System.out.println(generatePassword(8)); } private ... Read More

5K+ Views
Generate OTP is now a requirement on most of the website now-a-days. In case of additional authentication, system generates a OTP password adhering to OTP policy of the company. Following example generates a unique OTP adhering to following conditions −It should contain at least one number.Length should be 4 characters.Exampleimport java.util.Random; public class Tester { public static void main(String[] args) { System.out.println(generateOTP(4)); } private static char[] generateOTP(int length) { String numbers = "1234567890"; Random random = new Random(); char[] otp = new ... Read More

5K+ Views
Generate OTP is now a requirement on most of the website now-a-days. In case of additional authentication, system generates a OTP password adhering to OTP policy of the company. Following example generates a unique OTP adhering to following conditions −It should contain at least one number.Length should be 4 characters.Exampleimport java.util.Random; public class Tester { public static void main(String[] args) { System.out.println(generateOTP(4)); } private static char[] generateOTP(int length) { String numbers = "1234567890"; Random random = new Random(); char[] otp = new ... Read More

3K+ Views
In Java, the formatted output refers to a process of generating well-structured data by specifying how data should be displayed. It involves using format specifiers to control the appearance (visibility) of various data types, such as integers, floating-point numbers, strings, characters, and dates. In this article, we will discuss two key concepts about formatted output in Java as follows: Format Specifiers: Strings that define how some kinds of data should be formatted. Flags and Width: Options to control the run of the output, including aligning it, setting its padding, and regulating its width. Common Format Specifiers Format specifiers in Java ... Read More

3K+ Views
In Java, the formatted output refers to a process of generating well-structured data by specifying how data should be displayed. It involves using format specifiers to control the appearance (visibility) of various data types, such as integers, floating-point numbers, strings, characters, and dates. In this article, we will discuss two key concepts about formatted output in Java as follows: Format Specifiers: Strings that define how some kinds of data should be formatted. Flags and Width: Options to control the run of the output, including aligning it, setting its padding, and regulating its width. Common Format Specifiers Format specifiers in Java ... Read More

7K+ Views
A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following −Syntaxtry { // Protected code } catch (ExceptionName e1) { // Catch block }The code which is prone to exceptions is placed in the try block. When an exception occurs, that exception occurred is handled by catch block associated with it. Every try block should be immediately followed either by ... Read More

7K+ Views
A method catches an exception using a combination of the try and catch keywords. A try/catch block is placed around the code that might generate an exception. Code within a try/catch block is referred to as protected code, and the syntax for using try/catch looks like the following −Syntaxtry { // Protected code } catch (ExceptionName e1) { // Catch block }The code which is prone to exceptions is placed in the try block. When an exception occurs, that exception occurred is handled by catch block associated with it. Every try block should be immediately followed either by ... Read More

565 Views
Following programs shows the float arithmetic can cause dubious result if integer values are used using float variables.Examplepublic class Tester { public static void main(String[] args) { float a = 500000000; float b = -500000000; float c = 1; float sumabc1 = a+(b+c); float sumabc2 =(a+b)+c; System.out.println("Floating Point Arithmetic"); System.out.println("a + ( b + c ) : " + sumabc1); System.out.println("(a + b) + c : " + sumabc2); ... Read More

565 Views
Following programs shows the float arithmetic can cause dubious result if integer values are used using float variables.Examplepublic class Tester { public static void main(String[] args) { float a = 500000000; float b = -500000000; float c = 1; float sumabc1 = a+(b+c); float sumabc2 =(a+b)+c; System.out.println("Floating Point Arithmetic"); System.out.println("a + ( b + c ) : " + sumabc1); System.out.println("(a + b) + c : " + sumabc2); ... Read More