Nishtha Thakur has Published 582 Articles

Restrictions applied to Java static methods

Nishtha Thakur

Nishtha Thakur

Updated on 26-Jun-2020 15:50:46

If the static keyword is applied to any method, it becomes a static method.If a method is declared as static, it is a member of a class rather than belonging to the object of the class. It can be called without creating an object of the class. A static method ... Read More

Java 8 Streams and its operations

Nishtha Thakur

Nishtha Thakur

Updated on 26-Jun-2020 15:41:18

Streams are sequences of objects from a source, which support aggregate operations. These were introduced in Java 8.With Java 8, Collection interface has two methods to generate a Stream.stream() − Returns a sequential stream considering collection as its source.parallelStream() − Returns a parallel Stream considering collection as its source.Some operations ... Read More

Set the capacity value for a StringBuffer object in Java

Nishtha Thakur

Nishtha Thakur

Updated on 26-Jun-2020 15:34:47

The capacity() method returns the current capacity. It is a part of the StringBuffer. It is the quantity of storage present for recently inserted characters, after which an allocation occurs.Declaration - The capacity() method is declared in the java.lang.StringBuffer class as follows −public int capacity()The capacity of a StringBuffer object ... Read More

Get the length of a StringBuffer Object in Java

Nishtha Thakur

Nishtha Thakur

Updated on 26-Jun-2020 15:17:13

To find the length of the StringBuffer object, the length() function is used. It is a method of the StringBuffer Class. The method returns the count of characters in the sequence.Declaration- The java.lang.StringBuffer.length() method is declared as follows −public int length()Let us see an example program illustrating the use of ... Read More

Display the position of a Substring in Java

Nishtha Thakur

Nishtha Thakur

Updated on 26-Jun-2020 15:07:37

To display the position of a Substring in Java, we use the lastindexOf() method in Java. The lastindexOf() method returns the rightmost occurrence of the substring within a particular StringBuffer object.If the substring occurs more than once in the StringBuffer object, the index of the first character of the rightmost ... Read More

Animate CSS padding-right property

Nishtha Thakur

Nishtha Thakur

Updated on 25-Jun-2020 14:56:49

To implement animation on padding-right property with CSS, you can try to run the following code:ExampleLive Demo                    div {             width: 350px;             height: 150px;             outline: 3px solid orange;             animation: myanim 3s infinite;          }          @keyframes myanim {             30% {                padding-right: 60px;             }          }                     CSS padding-right property          

Animate CSS padding-bottom property

Nishtha Thakur

Nishtha Thakur

Updated on 25-Jun-2020 14:53:59

To implement animation on padding-bottom property with CSS, you can try to run the following code:ExampleLive Demo                 div {          width: 350px;          height: 150px;          outline: 3px solid blue;          animation: myanim 3s infinite;       }       @keyframes myanim {          50% {             padding-bottom: 30px;          }       }                     CSS padding-bottom property          

Cross-browser drag-and-drop HTML file upload?

Nishtha Thakur

Nishtha Thakur

Updated on 25-Jun-2020 07:50:35

For cross-browser HTML File Uploader, use FileDrop. It works on almost all modern web browsers.As per the official specification −FileDrop is a self-contained cross-browser for HTML5, legacy, AJAX, drag & drop, JavaScript file upload

HTML5 Audio to Play Randomly

Nishtha Thakur

Nishtha Thakur

Updated on 25-Jun-2020 07:38:46

To play randomly, add the songs like this −init ([    'http://demo.com/songs/song1.mp3,    'http://demo.com/songs/song2.mp3,    'http://demo.com/songs/song3.mp3 ]);Use the following to play randomly using Math.random −function displayRandom() {    var audio = Math.floor(Math.random() * (collection.length));    audio = collection[audio];    audio.play();    setTimeout(loop, audio.duration*1000); }Read More

Translating HTML5 canvas

Nishtha Thakur

Nishtha Thakur

Updated on 25-Jun-2020 07:20:55

Use the translate() method to translate canvas. HTML5 canvas provides a translate(x, y) method which is used to move the canvas and its origin to a different point in the grid.Here argument x is the amount the canvas is moved to the left or right, and y is the amount ... Read More

Advertisements