Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Java Articles
Page 75 of 450
Java object creation of Inherited class
The constructor is something responsible for the object creation of a particular class in Java. Along with other functions of the constructor, it also instantiates the properties/instances of its class. In Java by default super() keyword is used as the first line of the constructor of every class, here the purpose of this method is to invoke the constructor of its parent class so that the properties of its parent get well instantiated before subclass inherits them and use. The point that should remember here is when you create an object the constructor is called but it is not mandatory that ...
Read MoreJava program to find the percentage of uppercase, lowercase, digits and special characters in a String
This article will teach us how to transform a string into an array of characters in order to examine its composition. Next, we shall categorize every character as a numeric, special character, lowercase letter, or uppercase letter. The methods of Java Character class will be used to do this. For each group (uppercase, lowercase, numbers, and special characters), we'll compute the percentage and show the results. isUpperCase() : The Java Character isUpperCase() method determines if a character is an uppercase character or not. isLowerCase() : The Java Character isLowerCase() method determines if a character is a lowercase character or not. isDigit() : The ...
Read MoreJava program to print number series without using any loop
In this article, we will learn how to print a sequence of numbers in Java, ranging from 0 to 15. To do this, we'll use recursion rather than using loops like for loop or while loop. Recursion is a programming technique where a method calls itself to perform a sub-operation as necessary. Problem Statement Write a Java program to print Number series without using any loop Output The numbers without using a loop have been printed below0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, Java program to print number series without using ...
Read MoreJava program to combine two list by alternatively taking elements
Introduction The Java program to combine two lists by alternatively taking elements is a simple code snippet that takes in two lists of any type of object that can be stored in a list and returns a new list that contains elements from both input lists alternately. The program defines a method called alternateMerge that takes two lists as input and returns a new list that contains elements from both lists alternately. It determines the size of both lists and loops through the larger of the two lists. For each index in the loop, it adds the element from the ...
Read MoreJava program to set a range for displaying substring
In this article, we'll learn how to extract a specific range of characters from a string in Java using the substring() method. The substring(int beginIndex, int endIndex) method gets a part of a string from the beginIndex to just before the endIndex. Problem Statement Given a string, extract a substring from a specified range of indices. Input String: pqrstuvw Output Substring: stu Steps to set a range for displaying substring Following are the steps to set a range for displaying substring − Declare a string str. Initialize the string str with the ...
Read MoreJava Program to add Combo Box to JTable
In this article, we will learn how to add a JComboBox to a JTable in Java Swing. The JComboBox allows you to create a drop-down list within a table cell, enabling users to select from predefined options. Steps to add a combo box to JTable Following are the steps to add a combo box to JTable − First import the necessary packages. Initialize a JTable with 5 rows and 5 columns. Create a JComboBox and add items to it. Get the first column of ...
Read MoreBasic calculator program using Java
In this article, we will learn to create a basic calculator using Java. With a basic calculator, we can add, subtract, multiply, or divide two numbers. This is done using a switch case. A program that demonstrates this is given as follows − Problem Statement Write a program in Java to create a basic calculator for performing the basic arithmetic operations − Input Enter two numbers: 23Enter an operator (+, -, *, /): + Output The result is given as follows:2.0 + 3.0 = 5.0 Steps to create basic calculator Following are the steps to create a basic calculator program using ...
Read MoreJava program to find the maximum and minimum elements in a stack
Stacks are basic data structures that follow the Last in First Out principle also termed as LIFO. A stack has many use cases like organizing function calls and undoing actions. Often one might encounter a problem locating the biggest and smallest elements inside a stack, this article will demonstrate multiple methods to accomplish this task using Java. Understanding Stacks A stack is a linear data structure that allows operations at only one end, known as the top. The primary operations include: Push: Adding an element to the top of the stack. ...
Read MoreSend SMS Alert to saved contact in Java
Steps to Send SMS Alerts Using Java In this article, we'll explore how to send SMS alerts to saved contacts using Java. We will guide you on how to Send SMS alerts using Java to saved or unsaved Contacts. Following are the steps to do so − Setting up an account with the SMS provider. Adding provider Java library to your project. Writing Java code to send the SMS. Let's elaborate on the above steps. Setting up Account First of all, we need to set up ...
Read MoreJava program to find the smallest missing number
The smallest missing number is the smallest number that is missing from a stream of elements or in an Array. The stream may or may not contain continuous elements. If the stream is continuous then the smallest missing number is nothing but the Smallest Missing Number in a stream. In this section, we will discuss the various approaches to find a Smallest Missing Number in a stream of elements using Java programming language. Problem Statement Given a stream of integers find the smallest missing number from the stream. Input 1 arr=[1, 2, 3, 5, 6, 7, 8] Output 1 ...
Read More