Smita Kapse has Published 566 Articles

Get the declared method by name and parameter type in Java

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 12:29:02

568 Views

The declared method can be obtained by name and parameter type by using the java.lang.Class.getDeclaredMethod() method. This method takes two parameters i.e. the name of the method and the parameter array of the method.The getDeclaredMethod() method returns a Method object for the method of the class that matches the name ... Read More

Compare two char arrays in a single line in Java

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 12:26:39

3K+ Views

Two char arrays can be compared in Java using the java.util.Arrays.equals() method. This method returns true if the arrays are equal and false otherwise. The two arrays are equal if they contain the same number of elements in the same order.A program that compares two char arrays using the Arrays.equals() ... Read More

Get the list of all declared fields in Java

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 12:21:02

6K+ Views

The list of all declared fields can be obtained using the java.lang.Class.getDeclaredFields() method as it returns an array of field objects. These field objects include the objects with the public, private, protected and default access but not the inherited fields.Also, the getDeclaredFields() method returns a zero length array if the ... Read More

Generate Random double type number in Java

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 12:06:23

5K+ Views

In order to generate Random double type numbers in Java, we use the nextDouble() method of the java.util.Random class. This returns the next random double value between 0.0 (inclusive) and 1.0 (exclusive) from the random generator sequence.Declaration - The java.util.Random.nextDouble() method is declared as follows −public float nextDouble()Let us see a ... Read More

Display the current method name in Java

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 12:02:51

1K+ Views

The current method name that contains the execution point that is represented by the current stack trace element is provided by the java.lang.StackTraceElement.getMethodName() method.A program that demonstrates this is given as follows −Example Live Demopublic class Demo {    public static void main(String args[]) {       System.out.println     ... Read More

Detect folders in Safari with HTML5

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 08:02:02

76 Views

You can try to run the following code to detect folders in Safari −Array.prototype.forEach.call(e.dataTransfer.files, function (file) {    var r = new FileReader();    r.onload = function (event) {       addFile(file);    };    r.onerror = function (event) {       alert("Uploading folders isn't supported in Safari browser!");    }    r.readAsDataURL(file); });

How to prevent text select outside HTML5 canvas on double-click?

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 07:53:07

222 Views

To avoid the double click text issue −var canvas1 = document.getElementById('c'); canvas1.onselectstart = function () {    return false; }Note − The Canvas should not fill the width of the page and it is only 100 pixels wide.

cache.manifest works for the first time then fails in HTML

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 07:39:31

35 Views

Add the following in the bottom −NETWORK: *Set the version number of the manifest in the URL with the path.In addition, set −CACHE MANIFEST #rev ?v = 42 /css/style.css?v = 20 /js/myscript.js?v = 20

How to rotate an image with the canvas HTML5 element from the bottom center angle?

Smita Kapse

Smita Kapse

Updated on 25-Jun-2020 07:06:08

176 Views

Translate the image dimensions to 32, 120 −context.translate(32, 120);Now rotate the canvas −context.rotate(90 * Math.PI/180);Now draw the image −context.drawImage(img, -32, -120, 64, 120);

Set how many columns an element should span across with CSS

Smita Kapse

Smita Kapse

Updated on 24-Jun-2020 13:52:02

83 Views

To set how many columns an element should span, use the column-span property. You can try to run the following code to implement the column-span property:ExampleLive Demo                    .demo {             column-count: 4;     ... Read More

Advertisements