Given an array of type Integer, write a Java program to find the odd and even numbers from that array. Those numbers which are completely divisible by 2 are called even numbers and if a number gives 1 as a remainder on dividing with 2 is known as odd number. Printing Odd and Even Number from an Array To print odd and even number from an array in Java, use the following ways − Using for Loop Using stream API Using for Loop In this approach, use the for ... Read More
Let's say, we have a numeric value of type double and our task is to convert it into other numeric primitive data types. To perform this operation, we require explicit casting as double is the largest primitive datatype available in Java. The process of converting larger data type into smaller one is called as explicit casting, also known as narrowing casting. Data types are used to specify the type of values stored in different variables. In Java, there are 8 primitive data types, out of which 6 are numeric types, including double, float, int, long, byte, and short. Example Scenario ... Read More
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
A running total (also known as an accumulated total) of a list represents the sum of a sequence of elements. As new elements are added to the sequence, the running total continuously updates. To perform this operation in Java, we can use for loop and while loop in our program. The program will have a time complexity of O(n), where n is the number of elements in the list because it loops through the list once and performs a constant-time operation for each element in the list. List is an interface of Java Collection Framework that stores collections of objects. ... Read More
List and Tuples are built-in data types of Python programming language. They serve as a container to hold multiple values of same type as well as different data types. We can find several differences in both of these containers. Read this article to learn more about lists and tuples in Python and how they are different from each other. List in Python List is a container that contains different types of objects. In it, the elements are separated by commas and stored within square brackets. Each element of a list has a unique position index, starting from 0. ... Read More
As per the problem statement, we have to create an empty matrix and fill that matrix with the prime numbers starting from the smallest prime number i.e. 2. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For instance, let's take the number 7. When we divide 7 by any number other than 1 and 7, we get a remainder. For example, dividing 7 by 2 gives a remainder of 1, and dividing 7 by 3 gives a remainder of 1 as well. Therefore, 7 has no divisors other ... Read More
In JavaScript, the clearTimeout() and clearInterval() methods are used to clear timers. When we set a timer using setTimeout() or setInterval() methods, the browser allocates memory to track it. Therefore, we use these methods to release that memory and avoid unnecessary function calls. It is best practice to clear timers when they are no longer needed. In this article, we will learn how the clearTimeout() and clearInterval() methods help to clear timers. JavaScript clearTimeout() method The clearTimeout() method in JavaScript clears the timeout that has been previously set by the setTimeout() function. It accepts a single integer value as a ... Read More
To add an icon logo to the title bar of a website in HTML. The icon of the title bar is often referred to as a favicon (short for "favorites icon"). It appears in the browser tab, bookmarks, and history. What is a Favicon? A favicon is a small, 16x16 or 32x32 pixel image associated with a website or web page. It is used to display a visual representation of your company, brand or website. It helps users to quickly identify your site or company name among multiple open tabs. Steps to Add an Icon Logo in ... Read More
The form fields can be disabled with the help of CSS, and JavaScript. In this article, we will learn to disable the form input fields with the help of CSS. Sometimes we need to disable form fields for various reasons, such as preventing user input before certain conditions, or for other purposes. The disabled form field means the user can not interact with the input field. Approaches to Disable Form Fields There are two approaches to disabling the form input field, we will explain each approach in detail with code examples. Disable Form Fields ... Read More
To use PHP in HTML, you must enclose the PHP code with PHP start tag . In this article from the example we will learn to use and become comfortable with PHP in HTML. PHP (Hypertext Preprocessor) is a popular server-side scripting language used for web development. It allows you to embed dynamic content into your HTML. Approach to use PHP in HTML To effectively use PHP in HTML, you need to enclose PHP code within tags. Remember, PHP files must have a .php extension since PHP code is processed on the server before the page is ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP