Abhinaya has Published 75 Articles

How to overwrite a specific chunk in a byte array using java?

Abhinaya

Abhinaya

Updated on 16-Jun-2020 10:02:01

Java provides a ByteBuffer class which allows you to wrap an array into a byte buffer using its wrap() method. Once you did that you can replace the contents of the buffer using the position(): To select the starting position and, put(): To replace the data methods:ExampleLive Demoimport java.nio.ByteBuffer; public ... Read More

How to concatenate two arrays in java?

Abhinaya

Abhinaya

Updated on 16-Jun-2020 09:00:47

One way of doing it is, create an array of length equals to the sum of lengths of the two arrays and, add elements of both arrays to it one by one.ExampleLive Demopublic class HelloWorld {    public static void main(String[] args) {       int[]a = {1, 2, ... Read More

How to arguments object with Rest, default, and destructured parameters in JavaScript?

Abhinaya

Abhinaya

Updated on 15-Jun-2020 13:19:37

defaultThis came to handle function parameters with ease. Easily set Default parameters to allow initializing formal parameters with default values. This is possible only if no value or undefined is passed. Let’s see an exampleExampleLive Demo                    // default is set ... Read More

What is the role of screenY Mouse Event in JavaScript?

Abhinaya

Abhinaya

Updated on 23-May-2020 09:36:35

When an event is triggered, the screenY mouse event returns the vertical coordinate of the mouse pointer.ExampleYou can try to run the following code to learn how to implement screenY Mouse event in JavaScript.           Click here to get the x (horizontal) and y (vertical) ... Read More

What is the usage of onfocusout event in JavaScript?

Abhinaya

Abhinaya

Updated on 22-May-2020 11:16:24

The onfocusin event triggers when an element is to lose focus. You can try to run the following code to learn how to implement onfocusout event in JavaScript.Example           Write below:       After losing focus, the background color of input check will change.                      function newFunc(x) {             x.style.background = "blue";          }          

What is JavaScript Bitwise XOR (^) Operator?

Abhinaya

Abhinaya

Updated on 20-May-2020 10:50:12

If both the bits are different, then 1 is returned when Bitwise OR (|) operator is used.ExampleYou can try to run the following code to learn how to work with JavaScript Bitwise XOR Operator.                    document.write("Bitwise XOR Operator");          // 7 = 00000000000000000000000000000111          // 1 = 00000000000000000000000000000001          document.write(7 ^ 1);          

How to generate a random 128 bit strings using Python?

Abhinaya

Abhinaya

Updated on 05-Mar-2020 10:21:59

You can generate these just random 128-bit strings using the random module's getrandbits function that accepts a number of bits as an argument. exampleimport random hash = random.getrandbits(128) print(hex(hash))OutputThis will give the output −0xa3fa6d97f4807e145b37451fc344e58c

How to generate XML using Python?

Abhinaya

Abhinaya

Updated on 05-Mar-2020 10:14:32

To generate XML from a python dictionary, you need to install the dicttoxml package. You can install it using −$ pip install dicttoxmlOnce installed, you can use the dicttoxml method to create the xml. examplea = {    'foo': 45,    'bar': {       'baz': "Hello"    } } ... Read More

How can we use Python Ternary Operator Without else?

Abhinaya

Abhinaya

Updated on 05-Mar-2020 07:37:19

If you want to convert a statement like −if :    to a single line, You can use the single line if syntax to do so −if : Another way to do this is leveraging the short-circuiting and operator like − and If is false, then short-circuiting will kick ... Read More

Execute a script when the element is being clicked in HTML?

Abhinaya

Abhinaya

Updated on 03-Mar-2020 12:32:25

Use the onclick attribute to execute a script when the element is clicked in HTML.ExampleYou can try to run the following code to implement onclick attribute −           Click                      function display() {             document.getElementById("test").innerHTML = "You clicked the button!";          }          

Advertisements