Sreemaha has Published 74 Articles

What are all the ways keyword ‘this’ can be used in Java?

Sreemaha

Sreemaha

Updated on 16-Jun-2020 07:50:59

218 Views

You can use this keyword to –Differentiate the instance variables from local variables if they have same names, within a constructor or a method.class Student {    int age;    Student(int age) {       this.age = age;    } }Call one type of constructor (parametrized constructor or default) ... Read More

What is lexical this in JavaScript?

Sreemaha

Sreemaha

Updated on 16-Jun-2020 06:24:31

1K+ Views

Fat arrow function solves the issue of lexical binding “this”. It gets the context of “this “and you can fulfill the same purpose since fast arrow does not have its own this. Fat arrow function as the name suggests helps in decreasing line of code. The syntax => shows fat ... Read More

Create JS Radial gradient with matrix in HTML

Sreemaha

Sreemaha

Updated on 02-Jun-2020 07:40:33

154 Views

JSRadial gradient with matrix is created in the following way. You can try to run the following way to create JS Radial gradient with matrix −var canvas1 = document.getElementById("canvas"); //canvas1 variable to identify given canvas var ctx1 = canvas.getContext("2d"); //This is used to tell context is 2D   var ... Read More

Execute a script when the media is ready to start playing in HTML?

Sreemaha

Sreemaha

Updated on 30-May-2020 22:50:00

89 Views

Use the oncanplay attribute to define when an audio/ video is ready to start playing.ExampleYou can try to run the following code to learn how to execute a script when the media is ready to start playing −                       ... Read More

HTML 5 local Storage size limit for sub domains

Sreemaha

Sreemaha

Updated on 04-Mar-2020 04:57:24

380 Views

HTML5's localStorage databases are size-limited. The standard sizes are 5 or 10 MB per domain. A limit of 5 MB per origin is recommended.The following is stated −User agents should guard against sites storing data under their origin's other affiliated sites, e.g. storing up to the limit in a1.example.com, a2.example.com, ... Read More

How to set the audio output of the video to mute in HTML?

Sreemaha

Sreemaha

Updated on 03-Mar-2020 10:27:59

296 Views

Use the muted attribute to set the audio output of the video to mute. You can try to run the following code to implement muted attribute −Example                                        Your browser does not support the video element.          

How to specify the URL of the resource to be used by the object in HTML?

Sreemaha

Sreemaha

Updated on 03-Mar-2020 09:40:41

69 Views

Use the data attribute in HTML to specify the URL of the resource to be used by the object in HTML.ExampleYou can try to run the following code to implement the data attribute −           Demonstration                

How to remove an element from an array in Java

Sreemaha

Sreemaha

Updated on 24-Feb-2020 11:11:49

796 Views

Following example shows how to remove an element from array. Exampleimport java.util.ArrayList; public class Main {    public static void main(String[] args) {       ArrayList objArray = new ArrayList();       objArray.clear();       objArray.add(0, "0th element");       objArray.add(1, "1st element");       objArray.add(2, ... Read More

Why is char[] preferred over String for storing passwords?

Sreemaha

Sreemaha

Updated on 24-Feb-2020 10:31:39

104 Views

Yes, Storing password in String object is not safe for following reasons −String objects are immutable and until garbage collected, they remain in memory.String being plain text can be tracked in memory dump of the application.In log, String based password may be printed which can cause a problem.Char[] can be ... Read More

The most elegant ways to iterate the words of a java string.

Sreemaha

Sreemaha

Updated on 24-Feb-2020 10:25:38

2K+ Views

Just split the string based on space and then iterate it. See the example below −Examplepublic class Tester {    public static void main(String[] args) {       String test = "I love learning Java";       String[] subStrings = test.split(" ");       for(String subString: subStrings) {          System.out.println(subString);       }    } }OutputI love learning Java

Advertisements