
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

32K+ Views
Given a sentence (string), let's say str, count the total number of vowels in it. In Java, the String is a non-primitive data type which is used to define sequence of characters. And, the English letters a, e, i, o, and u are known as vowels. To count the number of vowels in a given sentence, create a variable named count and initialize it with 0. Store the number of occurrences in this variable. Next, compare each character in the sentence with the vowels. If a match occurs increment the count and print it. Counting Number of Vowels In ... Read More

32K+ Views
Given a sentence (string), let's say str, count the total number of vowels in it. In Java, the String is a non-primitive data type which is used to define sequence of characters. And, the English letters a, e, i, o, and u are known as vowels. To count the number of vowels in a given sentence, create a variable named count and initialize it with 0. Store the number of occurrences in this variable. Next, compare each character in the sentence with the vowels. If a match occurs increment the count and print it. Counting Number of Vowels In ... Read More

19K+ Views
An Armstrong number is a number which equals to the sum of the cubes of its individual digits. For example, 153 is an Armstrong number as −153 = (1)3 + (5)3 + (3)3 153 1 + 125 + 27 154 153Algorithm1. Take integer variable Arms. 2. Assign a value to the variable. 3. Split all digits of Arms. 4. Find cube-value of each digit. 5. Add all cube-values together. 6. Save the output to Sum variable. 7. If Sum equals to Arms print Armstrong Number. 8. If Sum does not equal to Arms print Not Armstrong Number.Example Below is an ... Read More

19K+ Views
An Armstrong number is a number which equals to the sum of the cubes of its individual digits. For example, 153 is an Armstrong number as −153 = (1)3 + (5)3 + (3)3 153 1 + 125 + 27 154 153Algorithm1. Take integer variable Arms. 2. Assign a value to the variable. 3. Split all digits of Arms. 4. Find cube-value of each digit. 5. Add all cube-values together. 6. Save the output to Sum variable. 7. If Sum equals to Arms print Armstrong Number. 8. If Sum does not equal to Arms print Not Armstrong Number.Example Below is an ... Read More

10K+ Views
In this article, we will count the number of consonants in a given sentence using Java to achieve this, we will use the Scanner class for user input and a for loop to iterate through each character in the sentence. By comparing each character with the vowels a, e, i, o, u, and ignoring spaces, we will identify consonants and increment a counter accordingly. The Scanner class is part of java.util package and is commonly used to obtain input from the user. Problem Statement Given a sentence, write a Java program to count the number of consonants. As given below ... Read More

10K+ Views
In this article, we will count the number of consonants in a given sentence using Java to achieve this, we will use the Scanner class for user input and a for loop to iterate through each character in the sentence. By comparing each character with the vowels a, e, i, o, u, and ignoring spaces, we will identify consonants and increment a counter accordingly. The Scanner class is part of java.util package and is commonly used to obtain input from the user. Problem Statement Given a sentence, write a Java program to count the number of consonants. As given below ... Read More

3K+ Views
For a character "ch", write a Java program to verify whether it lies between a and z (both small and capital). If it does it is an alphabet otherwise, not. Alphabets are the set of letters written to represent particular sounds in a spoken language like English. Example Scenario 1: Input: character = 'e'; Output: Yes given character is an alphabet Example Scenario 2: Input: character = '4'; Output: No given character is not an alphabet Using ASCII Values The term ASCII stands for American Standard Code for Information Interchange. Every English letters has an ASCII value ... Read More

3K+ Views
For a character "ch", write a Java program to verify whether it lies between a and z (both small and capital). If it does it is an alphabet otherwise, not. Alphabets are the set of letters written to represent particular sounds in a spoken language like English. Example Scenario 1: Input: character = 'e'; Output: Yes given character is an alphabet Example Scenario 2: Input: character = '4'; Output: No given character is not an alphabet Using ASCII Values The term ASCII stands for American Standard Code for Information Interchange. Every English letters has an ASCII value ... Read More

1K+ Views
In this article, we’ll learn to find the largest of three numbers using the ternary operator in Java. This simple yet effective approach allows you to write concise and readable code. Finding the largest of three numbers is a common programming task, and Java provides an efficient way to do this using the ternary operator. This concise approach reduces code complexity while maintaining readability. What is the Ternary Operator in Java? The ternary operator is a shorthand for if-else statements in Java. It uses the syntax: condition ? value_if_true : value_if_false This operator is useful for simple conditional checks and ... Read More

1K+ Views
In this article, we’ll learn to find the largest of three numbers using the ternary operator in Java. This simple yet effective approach allows you to write concise and readable code. Finding the largest of three numbers is a common programming task, and Java provides an efficient way to do this using the ternary operator. This concise approach reduces code complexity while maintaining readability. What is the Ternary Operator in Java? The ternary operator is a shorthand for if-else statements in Java. It uses the syntax: condition ? value_if_true : value_if_false This operator is useful for simple conditional checks and ... Read More