Karthikeya Boyini has Published 2193 Articles

Create Pair Tuple from List in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

944 Views

Use the fromCollection() method to create a Pair Tuple from List collection.Let us first see what we need to work with JavaTuples. To work with Pair class in JavaTuples, you need to import the following package −import org.javatuples.Pair;Note − Steps to download and run JavaTuples program. If you are using ... Read More

How to set result of a java expression in a property in JSP?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

168 Views

The tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java.util.Map object.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueInformation to saveNobodytargetName of the variable whose property should be ... Read More

Period ofMonths() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

217 Views

The Period can be obtained with the given number of months using the ofMonths() method in the Period class in Java. This method requires a single parameter i.e. the number of months and it returns the Period object with the given number of months.A program that demonstrates this is given ... Read More

Java Program to append all elements of other Collection to ArrayList

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

194 Views

Let us first create an ArrayList −ArrayListarr = new ArrayList(); arr.add("50"); arr.add("100"); arr.add("150"); arr.add("200"); arr.add("250"); arr.add("300");Now, let’s say we have another Collection as Vector −Vectorvector = new Vector(); vector.add("500"); vector.add("700"); vector.add("800"); vector.add("1000"); Append all the elements from the Vector to ArrayList: arr.addAll(vector);Example Live Demoimport java.util.ArrayList; import java.util.Vector; public class Demo { ... Read More

How to handle an exception in JSP?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

233 Views

The tag catches any Throwable that occurs in its body and optionally exposes it. It is used for error handling and to deal more gracefully with the problem.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultvarThe name of the variable to hold the java.lang.Throwable if thrown by elements in the ... Read More

C++ Program to Check Whether a Given Tree is Binary Search Tree

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

353 Views

Binary Search Tree is a binary tree data structure in which we have 3 propertiesThe left subtree of a binary search tree of a node contains only nodes with keys lesser than the node’s key.The right subtree of a binary search tree node contains only nodes with keys greater than ... Read More

Period ofWeeks() method in Java

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

197 Views

The Period can be obtained with the given number of weeks using the ofWeeks() method in the Period class in Java. This method requires a single parameter i.e. the number of weeks and it returns the Period object with the given number of weeks.A program that demonstrates this is given ... Read More

Java Program to generate custom random number -1 or 1

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

252 Views

To generate custom random number 1 or -1, you need to use nextBoolean(). At first take a loop and create a Random object on each iteration −for (int i = 0; i < 5; i++) {    Random rand = new Random(); }Now, use nextBoolean() to generate 1 on TRUE ... Read More

Resolve ERROR 1111 (HY000): Invalid use of group function in MySQL? How to correctly use aggregate function with where clause?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

2K+ Views

To correctly use aggregate function with where clause in MySQL, the following is the syntax −select *from yourTableName where yourColumnName > (select AVG(yourColumnName) from yourTableName);To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table EmployeeInformation    -> ( ... Read More

How to apply choose tag in JSP?

karthikeya Boyini

karthikeya Boyini

Updated on 30-Jul-2019 22:30:25

291 Views

The works like a Java switch statement in that it lets you choose between a number of alternatives. Where the switch statement has case statements, the tag has tags. Just as a switch statement has the default clause to specify a default action, has as ... Read More

Advertisements