Abhinaya has Published 75 Articles

Execute a script when the user opens or closes the
element in HTML?

Abhinaya

Abhinaya

Updated on 03-Mar-2020 06:51:55

When a user opens or closes the element, the ontoggle event fires. You can try to run the following code to implement ontoggle event attribute −Example           Details       You need to join office from Feb23                More Information          Timings: 9 to 5:30          Office location: Hyderabad                            function myFunction() {             alert("Timings, office location, etc");          }          

How to display the background color of an element in HTML?

Abhinaya

Abhinaya

Updated on 02-Mar-2020 12:44:56

Use the bgcolor attribute in HTML to display the background color of an element. It is used to control the background of an HTML element, specifically page body and table backgrounds.Note − This attribute is not supported in HTML5.ExampleYou can try to run the following code to learn how to implement ... Read More

Why do we use modifiers in C/C++?

Abhinaya

Abhinaya

Updated on 26-Feb-2020 11:17:42

A modifier is used to alter the meaning of the base type so that it works in accordance with your needs. For example, time cannot be negative and it makes sense to make it unsigned. C++ allows the char, int, and double data types to have modifiers preceding them. The ... Read More

How to use Java string replace method?

Abhinaya

Abhinaya

Updated on 26-Feb-2020 08:13:02

The replace() method of the String class returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.ExampleLive Demoimport java.io.*; public class Test {    public static void main(String args[]) {       String Str = new String("Welcome to Tutorialspoint.com");       System.out.print("Return Value ... Read More

How to get a substring of a particular string in Java. Explain with an example.

Abhinaya

Abhinaya

Updated on 26-Feb-2020 06:46:41

The substring(int beginIndex, int endIndex) method of the String class. It returns a new string that is a substring of this string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1. Thus the length of the substring is endIndex-beginIndex.ExampleLive Demoimport java.lang.*; public ... Read More

Command line arguments in Java

Abhinaya

Abhinaya

Updated on 25-Feb-2020 05:10:37

Sometimes you will want to pass some information on a program when you run it. This is accomplished by passing command-line arguments to main( ).A command-line argument is an information that directly follows the program's name on the command line when it is executed. To access the command-line arguments inside ... Read More

What does the method trimToSize() do in java?

Abhinaya

Abhinaya

Updated on 20-Feb-2020 12:21:01

The trimToSize() method of the java.util.ArrayList class trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String args[]) {       ArrayList ... Read More

What does the method clear() do in java?

Abhinaya

Abhinaya

Updated on 20-Feb-2020 12:15:41

The clear() method of the class java.util.ArrayList removes all of the elements from this list. The list will be empty after this call returns.Exampleimport java.util.ArrayList; public class ArrayListDemo {    public static void main(String[] args) {       ArrayList arrlist = new ArrayList(5);       arrlist.add(20);   ... Read More

How to create and write JSON array to a file in java?

Abhinaya

Abhinaya

Updated on 19-Feb-2020 12:26:38

Java provides javax.json.Json package which contains classes to read a JSON array:Exampleimport java.io.FileOutputStream; import javax.json.Json; import javax.json.JsonArray; import javax.json.JsonWriter; public class JSONArrayToFile {    public static void main(String args[]) throws Exception {       JsonArray value = Json.createArrayBuilder()          .add(Json.createObjectBuilder()          .add("id", ... Read More

How to divide an array into half in java?

Abhinaya

Abhinaya

Updated on 19-Feb-2020 11:21:36

Using the copyOfRange() method you can copy an array within a range. This method accepts three parameters, an array that you want to copy, start and end indexes of the range.You split an array using this method by copying the array ranging from 0 to length/2 to one array and length/2 ... Read More

Advertisements