Suppose you are given two strings, your task is to write a Java program that checks whether the second string is the sub-string of the first one. String in Java is an immutable sequence of characters and sub-string is its small portion. Example Scenario: − Input 1: str = "The sunset is beautiful"; Input 2: sub_str = "sunset"; Output: res = found!! Using Iteration In this approach, the idea is to use a nested for loop and an if block. The outer for loop will iterate over the characters of the main string. For each starting position i, ... Read More
Given a sentence or string, write a Java program to reverse each word in that sentence. Each word in that sentence should be reversed and at the same time, they should be in the same order as before. Let's understand the problem with an example − Example Scenario: Input: orgnl_sen = an apple is red Output: modfd_sen = na elppa si der Using Iteration First, split the given sentence into an array of words using the space character as the delimiter. Use a for-each loop to iterate over each word. Then, iterate through the characters of each ... Read More
Given a String, let's say "str", write a Java program to reverse it. In reverse string operation, we need to display the individual characters of string backwards or from right to left. Here, String is a datatype that contains one or more characters and is enclosed in double quotes(“ ”). Let's understand the problem with an example − Example Scenario: − Input: str = "Java Program"; Output: reversed_string = margorP avaJ For better understanding refer to the below illustration − Reverse String .main { background-color: rgb(151, 231, 89); ... Read More
To create a box filled with color in HTML/CSS, it can be achieved with HTML as we can create a simple frame of the box with the help of HTML and to fill the color we can use the CSS property. We will be discussing two different approaches to create a box filled with color. In this article, we are having a div or we can have any block element and our task is to create a box filled with color in HTML/CSS. Approaches to create a box filled with color Here is a list of approaches to create a ... Read More
If you want users to click on links and open those links in a new window becouse you want your user to stay on your site while they view the linked content. Then you need to use this solution. By using JavaScript you can easily configure all of your links so that they open in a new window when clicked. Approach to Open Link in a New Window Using window.open() Method Using window.open() Method JavaScript window.open() method allows you to open a new browser window or tab, with the specified URL. ... Read More
To adjust CSS for specific zoom level, we will be using CSS media queries which changes the div box style for different zoom levels. In this article, we will be discussing step wise process for using media queries to adjust CSS for specific zoom level. In this article, we are having a div box with initial green background and our task is to adjust CSS for specific zoom level. Steps to Adjust CSS for Specific Zoom Level We will be following below mentioned steps to adjust CSS for specific zoom level. We have used div ... Read More
Assume we have created a table in database and the table consists of duplicate records or, you need to check if there are multiple entries of the same record in the database. In order to find such duplicate records you can make use of below sample queries. Printing Duplicate Rows in an SQL Table Lets consider we have a table named as Students with the columns ID, Name, Age. Using the following query − CREATE TABLE Students( ID INT NOT NULL, NAME VARCHAR (20) NOT NULL, AGE ... Read More
To change layouts based on screen size in CSS, we will create a parent div and wrap other children divs within it. Using Media Queries, the layout of the screen size will be changed. Media Queries is used when you need to set a style to different devices such as tablet, mobile, desktop etc. In this article, we are having four boxes of same width, our task is to change layouts based on screen size in CSS. Steps to Chnage Layouts Based on Screen Size We will be following below mentioned steps to change layouts based on screen size in ... Read More
In this article, we will learn how to remove the n-th character from a string in Java. The program takes an input string and an index, removes the character at the given index, and returns the modified string and this process will be demonstrated through a simple example, using the substring() method. Problem Statement Write a program in Java that removes the n-th character from a given string. The program will display the original string and the string after the character is removed − Input Original string: Apple Output String with 4th character removed: Appe Steps to remove n-th character from ... Read More
In this article, we will learn to convert a byte array into an IP address using the IPAddress class in Java. This program takes a series of bytes, representing an IP address in binary form, and converts them into a standard dot-separated string representation of an IP address. We'll go through the simple steps of declaring a byte array and then converting it into a readable IP address format. What is a Byte Array? A byte comprises 8 bits and a byte array comprises contiguous bytes which store the binary information. In Java, a byte is a primitive datatype that can ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP