Combine Two Lists by Alternately Taking Elements in Java

Bharti Kumari
Updated on 21-Aug-2024 00:06:57

1K+ Views

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 More

Get Lowest and Highest Value in TreeSet in Java

Krantik Chavan
Updated on 21-Aug-2024 00:03:22

2K+ Views

In this article, we will learn how to find the lowest and highest values in a TreeSet in Java. The TreeSet class, part of the java.util package, automatically sorts its elements in natural order. We will use the first() and last() methods of the TreeSet class to retrieve the smallest and largest elements, respectively Problem Statement Write a Java program to get the lowest and highest value in TreeSet. Input 50, 100, 150, 200, 250, 300, 400, 500, 800, 1000 Output TreeSet Lowest value = 50TreeSet Highest value = 1000 Steps to get the lowest and highest value in TreeSet ... Read More

Split String in Java Using Regular Expression

V Jyothi
Updated on 21-Aug-2024 00:03:07

6K+ Views

In this article, we will learn to split a string in Java using regular expressions. We will be using the split(String regex) method of the String class to split this string around matches of the given regular expression. This method works in the same way as invoking the method i.e. split(String regex, int limit) with the given expression and a limit argument of zero. Therefore, trailing empty strings are not included in the resulting array. Steps to split string in Java using regular expression Following are the steps to split strings in Java using regular expression − ... Read More

Set Alternate Table Row Color Using CSS

Shabaz Alam
Updated on 20-Aug-2024 14:51:49

11K+ Views

To set alternate table row color using CSS, is also known as zebra striping. It is helpful in improving the readability of table as it is easier to distinguish between rows. In this article, we will be understanding four different approaches to set alternate table row color using CSS. We are having a 5*2 table, our task is to set alternate table row color using CSS. Approaches to Set Alternate Table Row Color Here is a list of approaches to set alternate table row color using CSS which we will be discussing in this article with stepwise explaination and complete ... Read More

Best Examples of Strengths and Weaknesses for Job Interviews

Savitha Muthukrishnan
Updated on 20-Aug-2024 12:41:26

190 Views

When you are preparing for a Job interview, it is important to do your homework in terms of understanding the Company for which you are applying, its vision and goals, services and products offered, geography, and leadership team. It is also important to be able to articulate your skills, technical or non-technical, relevant to the position you are applying for and why you would be a best fit for the role. While a lot of emphasis is given to the skills relevant to the job, it is equally important to evaluate competence on soft skills and interpersonal skills. When it comes ... Read More

Difference Between Orthographic and Isometric Projection

Shirjeel Yunus
Updated on 20-Aug-2024 11:48:12

4K+ Views

Projection is a computer graphics system in which an image is shown in various dimensions. This helps to view 3D images into their 2D counterparts. Projection can be of two types which include Orthographic and Isometric Projection. In this article, we will discuss the difference between Orthographic and Isometric Projections. What is Orthographic Projection? Orthographic projection is a type of projection in which the projection and view plane are perpendicular to each other. Orthographic projection is a method in which 3D objects are converted into 2D objects and displayed on the screen. Projectors are arranged parallel to each other and ... Read More

Difference Between JPEG and MPEG

Shirjeel Yunus
Updated on 20-Aug-2024 11:35:40

2K+ Views

JPEG is a format for storing images on a computer. A lossy compression algorithm is used to store images due to which some of the data related to an image is lost. MPEG is used for compressing video files. In this article, we will discuss the difference between JPEG and MPEG. What is JPEG? The full form of JPEG is Joint Photographic Experts Group. This is a format in which two extensions are used to store an image. One of them is .jpg and the other is .jpeg. JPEG is a popular image format and there are many advantages of ... Read More

Set a Range for Displaying Substring in Java

karthikeya Boyini
Updated on 19-Aug-2024 18:33:51

2K+ Views

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 More

Add Combo Box to JTable in Java

Chandu yadav
Updated on 19-Aug-2024 18:30:53

2K+ Views

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 More

Basic Calculator Program Using Java

karthikeya Boyini
Updated on 19-Aug-2024 18:30:26

24K+ Views

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 More

Advertisements