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
Java Articles - Page 651 of 745
2K+ Views
To find the smallest from three given numbers using ternary operator, create a temporary variable to store the result of first comparison operation between two numbers. Then, perform second comparison operation between the result of first operation (i.e. temp) and third number to get the final result. Let's understand the problem statement with an example − Example Scenario: Input: nums = 20, 35, 10; Output: res = 10 What is Ternary Operator? The conditional operator in Java is also known as the ternary operator. This operator consists of three operands and is used to evaluate Boolean expressions. The goal ... Read More
17K+ Views
The following program accepts average from the user, calculates the grade and prints it.Examplepublic class CalculateStudentGrades { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter average of your marks (less than 100)::"); int average = sc.nextInt(); char grade; if(average>=80){ grade = 'A'; }else if(average>=60 && average=40 && average
17K+ Views
The following program accepts average from the user, calculates the grade and prints it.Examplepublic class CalculateStudentGrades { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.println("Enter average of your marks (less than 100)::"); int average = sc.nextInt(); char grade; if(average>=80){ grade = 'A'; }else if(average>=60 && average=40 && average
1K+ Views
In this article, we will learn to reverse an array in Java. Reversing an array is a classic problem that helps understand essential concepts like data structures and in-place manipulation. This operation is commonly required in programming tasks, such as data transformations, algorithm implementations, and solving logical problems. Problem Statement Reversing an array involves rearranging its elements so that the first element becomes the last, the second becomes the second-to-last, and so on. Input int[] myArray = {23, 93, 56, 92, 39}; Output {39, 92, 56, 93, 23} Different Approaches Following are the two different approaches to reverse an array ... Read More
1K+ Views
In this article, we will learn to reverse an array in Java. Reversing an array is a classic problem that helps understand essential concepts like data structures and in-place manipulation. This operation is commonly required in programming tasks, such as data transformations, algorithm implementations, and solving logical problems. Problem Statement Reversing an array involves rearranging its elements so that the first element becomes the last, the second becomes the second-to-last, and so on. Input int[] myArray = {23, 93, 56, 92, 39}; Output {39, 92, 56, 93, 23} Different Approaches Following are the two different approaches to reverse an array ... Read More
3K+ Views
A switch statement in Java allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. To verify whether given character is a vowel read a character from the user into a variable (say ch). Problem Statement Given a character, write a Java program to determine whether it is a vowel or a consonant using a switch statement. Input Enter a character : a Output Given character is an vowel Steps to check whether given character is vowel or ... Read More
3K+ Views
A switch statement in Java allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each case. To verify whether given character is a vowel read a character from the user into a variable (say ch). Problem Statement Given a character, write a Java program to determine whether it is a vowel or a consonant using a switch statement. Input Enter a character : a Output Given character is an vowel Steps to check whether given character is vowel or ... Read More
4K+ Views
Comparing three integer variables is one of the simplest programs you can write at ease. Take two integer variables, say A, B& C Assign values to variables If A is greater than B & C, Display A is the largest value If B is greater than A & C, Display B is the largest value If C is greater than A & B, Display A is the largest value Otherwise, Display A, B & C are not unique valuesExampleimport java.util.Scanner; public class LargestOfThreeNumbers { public static void main(String args[]){ Scanner sc =new Scanner(System.in); System.out.println("Enter 1st number :"); ... Read More
4K+ Views
Comparing three integer variables is one of the simplest programs you can write at ease. Take two integer variables, say A, B& C Assign values to variables If A is greater than B & C, Display A is the largest value If B is greater than A & C, Display B is the largest value If C is greater than A & B, Display A is the largest value Otherwise, Display A, B & C are not unique valuesExampleimport java.util.Scanner; public class LargestOfThreeNumbers { public static void main(String args[]){ Scanner sc =new Scanner(System.in); System.out.println("Enter 1st number :"); ... Read More
5K+ Views
In this article, we'll generate the Fibonacci series using a while loop in Java. The Fibonacci series is a sequence where each number is the sum of the two previous numbers, starting with two initial numbers, usually either (0, 1) or (1, 1). Here, we start with (1, 1) and use a while loop to print the next numbers in the sequence until a specified limit. Steps to print the Fibonacci series using while loop Following are the steps to print the Fibonacci series using the while loop − Define a class and initialize three variables: a ... Read More