Karthikeya Boyini has Published 2383 Articles

Subtract days from current date using Calendar.DATE in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:37:55

2K+ Views

Import the following package for Calendar class in Java.import java.util.Calendar;Firstly, create a Calendar object and display the current date.Calendar calendar = Calendar.getInstance(); System.out.println("Current Date = " + calendar.getTime());Now, let us subtract the days using the add() method and Calendar.DATE constant. Set a negative value here since we are decrementing.calendar.add(Calendar.DATE, -2);Example Live ... Read More

Date.getUTCMilliseconds() function in JavaScript

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:36:41

32 Views

The Date object is a data type built into the JavaScript language. Date objects are created with the new Date( ) as shown below.Once a Date object is created, a number of methods allow you to operate on it. Most methods simply allow you to get and set the year, ... Read More

Prefix sum array in python using accumulate function

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:31:53

382 Views

Given an array and we have to do the prefix sum array using accumulate function.itertools.accumulate(iterable[, func]) module functions all construct and return iterators. So they should only be accessed by functions or loops that truncate the stream. Make an iterator that returns accumulated sums. Elements may be any addable type ... Read More

Perform Animation on the background-color property with CSS

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:29:50

93 Views

To implement animation on the background-color property with CSS, you can try to run the following codeExampleLive Demo                    div {             width: 400px;             height: 300px;             background: yellow;             animation: myanim 3s infinite;          }          @keyframes myanim {             20% {                background-color: maroon;             }          }                        

Basic calculator program using Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:21:45

17K+ Views

A basic calculator is able to add, subtract, multiply or divide two numbers. This is done using a switch case. A program that demonstrates this is given as follows −Exampleimport java.util.Scanner; public class Calculator {    public static void main(String[] args) {       double num1;       ... Read More

Clear a bit in a BigInteger in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:06:01

195 Views

To clear a bit in a BigInteger in Java, use the clearBit() method. It returns a BigInteger whose value is equivalent to this BigInteger with the designated bit cleared.Example Live Demoimport java.math.*; public class BigIntegerDemo {    public static void main(String[] args) {       BigInteger one, two;     ... Read More

Java Program to shift bits in a BigInteger

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 11:01:12

75 Views

To shift bits in a BigInteger, use the shiftLeft() or shiftRight() method.shiftLeft() methodThe java.math.BigInteger.shiftLeft(int n) returns a BigInteger whose value is (this > n). Sign extension is performed. The shift distance, n, may be negative, in which case this method performs a left shift. It computes floor(this / 2n).Example Live Demoimport ... Read More

Convert LinkedList to ArrayList in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 10:39:09

5K+ Views

A LinkedList can be converted into an ArrayList by creating an ArrayList such that the parameterized constructor of the ArrayList initialises it with the elements of the LinkedList.A program that demonstrates this is given as follows −Example Live Demoimport java.util.ArrayList; import java.util.LinkedList; import java.util.List; public class Demo {    public static ... Read More

Usage of element() method of Queues in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 10:37:14

631 Views

The element() method in Java Queues is used to return the element at the front of the container and does not remove it.The following is an example. Firstly, create a Queue and add some elements −Queue q = new LinkedList(); q.offer("abc"); q.offer("def"); q.offer("ghi"); q.offer("jkl"); q.offer("mno"); q.offer("pqr"); q.offer("stu"); q.offer("vwx");Now use the ... Read More

Queue poll() method example in Java

karthikeya Boyini

karthikeya Boyini

Updated on 25-Jun-2020 10:35:02

2K+ Views

Fetch and remove the first element in Queue using the poll() method.Create a queue −Queue q = new LinkedList();Add some elements −q.add("abc"); q.add("def"); q.add("ghi"); q.add("jkl"); q.add("mno"); q.add("pqr"); q.add("stu"); q.add("vwx");Now, remove the first element −q.poll()The following is an example to implement the poll() method −Example Live Demoimport java.util.LinkedList; import java.util.Queue; public class ... Read More

Advertisements