In this article, we will understand how to print a mirror lower star triangle pattern in Java. The program will use loops and print statements to get the output that we want, allowing us to get the pattern based on the number of rows specified by the user or predefined in the code. Problem Statement Write a Java program to print a mirror lower star triangle pattern. Below is a demonstration of the same − Input Enter the number of rows : 8 Output The mirror lower star triangle pattern : * * * * * * * * ... Read More
In this article, we will reverse the elements of an array up to a specified position using Java. You will learn how the program takes an array, reverses the first part of it up to a given index, and prints the modified array. An array can be reversed upto the given position pos and the remaining array is unchanged.Problem Statement Write a Java program to reverse an array upto a given position.Input Array = 1 2 3 4 5 6 7 8 9 10 Position = 6 Output Modified array is: 6 5 4 3 2 1 7 8 9 ... Read More
In this article, we will learn to check if the string contains any character in the given set of characters in Java. We will iterate over the string and compare each character to a set of characters that we want to search for. If any match is found, the program will print the character and confirm that it is present in the string. Problem Statement Write a program in Java to check if the string contains any character in the given set of characters − Input str = abcde chSearch = 'b', 'c' Output Character b found in string abcde ... Read More
In this article, we will learn to print common characters of two strings in alphabetical order using Java. The program uses arrays to count how often each letter appears in both strings and then compares these counts to identify the common characters. Problem Statement Write a Java program to print common characters of two strings in alphabetical order − Input my_str_1 = "itsasample" my_str_2 = "thisisasample" Output The common characters between the two strings in alphabetical order is :aaeilmpsst Steps to print common characters of two strings in alphabetical order Following are the steps to print common characters of two strings ... Read More
To count occurrences of vowels in a string again use the Map utility of Java as used in calculating the occurrence of each character in the string. Put each vowel as a key in Map and put the initial value as 1 for each key. Now compare each character with the key of the map if a character matches with a key then increase its corresponding value by 1. Steps to check occurrence of each vowel in String Following are the steps to check occurrence of each vowel in String − First, we will define ... Read More
In this article, we will understand how to print X star pattern using Java. The pattern is formed by using multiple for-loops and print statements. The pattern forms the shape of the letter "X" by printing stars ('X') and spaces in specific positions. The user can provide a number as input, which will determine the size of the pattern. The program uses nested loops to create the required star pattern, where stars are placed at the diagonal positions of a grid. Problem Statement Write a program in Java to print X star pattern. Below is a demonstration of the same: ... Read More
In this article, we will learn to generate random numbers with restrictions in Java. We will be using the Java Random class from java.util package. Random class Random class is imported from java.util package. The instance of this class is used to generate the random numbers and provides different numbers of different types integer, double, long, float, etc. Steps to generate random numbers with restrictions Following are the steps to generate random numbers with restrictions − Import the Random class from the java.util package. Initialize the Random object to generate random values. ... Read More
In Java, converting integers to different numeral systems can be easily achieved using built-in methods. The Integer.toOctalString(int) method allows you to convert an integer to its octal string representation. This is particularly useful in applications that require data representation in octal format. To convert integer to octal in Java, use the Integer.toOctalString() method. Problem Statement Given a set of integer values, we need to convert each integer to its octal string representation using the Integer.toOctalString(int) method. Input int val = 768; Output Octal String = 1400 Step to convert the integer to octal Below are the steps to convert integer ... Read More
The Java heap is a particular memory area which is used to store the objects and represent them as or by an instance in Java Virtual Machine. The Java heap can be shared between two threads as long as the environment is occupied by some running applications. The heaps are sorted in a stack memory and follow the Last In First Out (LIFO) method after the creation of an object in JVM. When the size of the heap memory is compared to the stack, the spare objects are cleared by the GarbageCollector automatically. The heap memory is divided into three ... Read More
A timetable is an essential tool for organizing daily activities and improving productivity. In this article, you will get to know how to create a simple and effective weekly timetable using HTML. This timetable will include time slots, subjects, and lunch breaks, along with highlighting weekends as holidays. HTML Tags used to create Time - Table The main tag used for creating a table is the tag in HTML elements. Tables allow us to represent structured data in rows and columns, which makes them perfect for displaying time schedules. List of tags required to create a time-table ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP