Karthikeya Boyini has Published 2383 Articles

Period ofMonths() method in Java

karthikeya Boyini

karthikeya Boyini

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

159 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

135 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

Create Unit Tuple in Java

karthikeya Boyini

karthikeya Boyini

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

104 Views

To create a Unit Tuple in Java is quite easy.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Let us see an example.Note − Steps to download and run JavaTuples program. If ... Read More

How to handle an exception in JSP?

karthikeya Boyini

karthikeya Boyini

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

169 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

225 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

109 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

164 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

223 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

LocalDate query() Method in Java

karthikeya Boyini

karthikeya Boyini

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

111 Views

The LocalDate object can be queried as required using the query method in the LocalDate class in Java. This method requires a single parameter i.e. the query to be invoked and it returns the result of the query.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import ... Read More

Advertisements