Implement Binary Search on Double Array in Java

Arjun Thakur
Updated on 25-Jun-2020 14:45:34

346 Views

Binary search on a double array can be implemented by using the methodjava.util.Arrays.binarySearch(). This method returns the index of the required double element if it is available in the array, otherwise it returns (-(insertion point) - 1) where the insertion point is the position at which the element would be inserted into the array.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo {    public static void main(String[] args) {       double d_arr[] = { 5.2, 7.5, 9.7, 1.8, 4.0 };       Arrays.sort(d_arr);       System.out.print("The sorted array is: ... Read More

Animate Transform Origin Property with CSS Animation

Ankith Reddy
Updated on 25-Jun-2020 14:44:43

1K+ Views

To implement animation on the transform-origin property with CSS, you can try to run the following codeExampleLive Demo                    #demo1 {             position: relative;             height: 300px;             width: 400px;             border: 2px solid black;             margin: 100px;             padding: 5px;          }          #demo2 {             padding: 30px;             position: absolute;             border: 1px solid black;             background-color: orange;             transform: rotate(45deg);             transform-origin: 30% 10%;             animation: mymove 3s infinite;          }          @keyframes mymove {             30% {                transform-origin: 0 0 0;             }          }                     CSS transform-origin property                Demo          

CSS rest-before Speech Media Property

Arjun Thakur
Updated on 25-Jun-2020 14:44:08

133 Views

The CSS rest-after property is useful for speech media to set pause before an element.Let us see an example of rest-before speech media propertyh1 {    rest-before: 15ms; }The time sets the pause in milliseconds.

Schedule Tasks in Java for Repeated Fixed Delay Execution

Arjun Thakur
Updated on 25-Jun-2020 14:43:41

1K+ Views

One of the methods in the Timer class is the void schedule(TimerTask task, long delay, long period) method. This method schedules tasks for repeated fixed-delay execution, beginning after the specified delay.In fixed-delay execution, each execution is scheduled with respect to the original execution time of the preceding execution. If an execution is delayed for a particular reason (case in point, garbage collection), the subsequent executions will be delayed as well.Declaration −The java.util.Timer.schedule(TimerTask task, long delay, long period) is declared as follows −public void schedule(TimerTask task, long delay, long period)Here, task is the task to be scheduled, delay is the delay ... Read More

Perform Animation on CSS min-height

Chandu yadav
Updated on 25-Jun-2020 14:42:24

327 Views

To implement animation on min-height property with CSS, you can try to run the following codeExampleLive Demo                    div {             overflow: auto;             width: 350px;             background-color: blue;             color: white;             border: 1px solid black;             animation: myanim 3s infinite;          }          @keyframes myanim {             ... Read More

CSS voice-duration Speech Media Property

George John
Updated on 25-Jun-2020 14:41:51

217 Views

The voice-duration property in CSS is used where synchronization of speech is done with other media.The following is an example to implement the voice-duration speech media propertyp {    voice-duration: 5s; }Above you can set auto value also.The auto value rectify a used value corresponding to the duration of the speech synthesis when using the inherited voice-rate. This is when you use inherited voice-rate.

CSS voice-balance Speech Media Property

Ankith Reddy
Updated on 25-Jun-2020 14:41:22

170 Views

Use the voice-balance property to set whether the spoken voice is from the left or right, etc.The following is a syntax to set the volume from left or right or centervoice-balance: left | center | rightLet us see an example to implement the voice-balance speech media propertyp {    voice-balance: right; }

Dump Array Content in Java

Ankith Reddy
Updated on 25-Jun-2020 14:40:53

358 Views

An array can be easily printed by using the method java.util.Arrays.toString() in Java. This method returns a string representation of the array contents that is enclosed in square brackets. If the array is null, then this method returns null.A program that demonstrates this is given as follows −Example Live Demoimport java.util.Arrays; public class Demo {    public static void main(String args[]) {       String str[] = {"John", "Harry", "Sally", "Emma", "Peter"};       System.out.println("The array content is:");       System.out.println(Arrays.toString(str));    } }OutputThe array content is: [John, Harry, Sally, Emma, Peter]Now let us understand the above program.The ... Read More

Perform Animation on CSS max-width

Arjun Thakur
Updated on 25-Jun-2020 14:40:38

1K+ Views

To implement animation on max-width property with CSS, you can try to run the following codeExampleLive Demo                    div {             overflow: auto;             background-color: blue;             color: white;             border: 1px solid black;             animation: myanim 3s;          }          @keyframes myanim {             30% {               ... Read More

Linked List in Java

Chandu yadav
Updated on 25-Jun-2020 14:40:33

500 Views

The LinkedList class extends AbstractSequentialList and implements the List interface. It provides a linked-list data structure.Following are the constructors supported by the LinkedList class.Sr.No.Constructor & Description1LinkedList( )This constructor builds an empty linked list.2LinkedList(Collection c)This constructor builds a linked list that is initialized with the elements of the collection c.Apart from the methods inherited from its parent classes, LinkedList defines following methods.Sr.No.Method & Description1void add(int index, Object element)Inserts the specified element at the specified position index in this list. Throws IndexOutOfBoundsException if the specified index is out of range (index < 0 || index > size()).2boolean add(Object o)Appends the specified element ... Read More

Advertisements