Articles on Trending Technologies

Technical articles with clear explanations and examples

How to capture divide by zero exception in Java?

Swarali Sree
Swarali Sree
Updated on 11-Mar-2026 2K+ Views

When you divide a number by zero an Arithmetic Exception number is thrown.Examplepublic class DividedByZero {    public static void main(String args[]) {       int a, b;       try {          a = 0;          b = 54/a;          System.out.println("hello");       } catch (ArithmeticException e) {          System.out.println("you cannot divide a number with zero");       }    } }Outputyou cannot divide a number with zero

Read More

How to call a JavaScript function from an onClick event?

varun
varun
Updated on 11-Mar-2026 2K+ Views

The onClick event is the most frequently used event type, which occurs when a user clicks the left button of the mouse. You can put your validation, warning etc., against this event type.ExampleYou can try to run the following code to call a JavaScript function from an onClick event                                         Click the following button and see result                          

Read More

How to call a JavaScript function from an onmouseover event?

varma
varma
Updated on 11-Mar-2026 2K+ Views

The onmouseover event triggers when you bring your mouse over any element.ExampleYou can try to run the following example to learn how to call a JavaScript function from onmouseover event                                         Bring your mouse inside the division to see the result:                 This is inside the division          

Read More

What does language attribute do in <script> tag in Javascript?

Sai Subramanyam
Sai Subramanyam
Updated on 11-Mar-2026 1K+ Views

The language attribute is used to mention the scripting language. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute. Yes, it is now deprecated. Here you can see how it was used.

Read More

What is the difference between “lang” and “type” attributes in a script tag?

Arushi
Arushi
Updated on 11-Mar-2026 331 Views

JavaScript lang attributeThis attribute specifies what scripting language you are using. Typically, its value will be javascript. Although recent versions of HTML (and XHTML, its successor) have phased out the use of this attribute.JavaScript type attributeThis attribute is what is now recommended to indicate the scripting language in use and its value should be set to "text/javascript".Here you can see how it is used:                              

Read More

What is the difference between System.out.println() and System.out.print() in Java?

Sharon Christine
Sharon Christine
Updated on 11-Mar-2026 2K+ Views

The println() terminates the current line by writing the line separator string. The print() method just prints the given content.Examplepublic class Sample {    public static void main(String args[]) {       System.out.println("Hello");       System.out.println("how are you");       System.out.print("Hello");       System.out.print("how are you");    } }OutputHello how are you Hellohow are you

Read More

How to get the input value of the first matched element using jQuery?

David Meador
David Meador
Updated on 11-Mar-2026 1K+ Views

To get the input value of the first matched element using jQuery, use the .first() method.ExampleYou can try to run the following code to get the input value of the first matched element using jQuery −                          $(document).ready(function(){            $( "li" ).first().css( "background-color", "blue" );          });                              One          Two          Three          Four          

Read More

How can I get the selected value of a drop-down list with jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 8K+ Views

With jQuery, it’s easy to get selected text from a drop-down list. This is done using the select id. To change the selected value of a drop-down list, use the val() method.ExampleYou can try to run the following code to learn how to change the selected value of a drop-down list. Here, we have a default select option first, but the alert shows the second option, which have been changed using the val method():           jQuery Selector                          $(document).ready(function() {         ...

Read More

How to get the value of div content using jQuery?

Alex Onsman
Alex Onsman
Updated on 11-Mar-2026 27K+ Views

To get the value of div content in jQuery, use the text() method. The text() method gets the combined text contents of all matched elements. This method works for both on XML and XHTML documents.ExampleYou can try to run the following code to get the value of div content using jQuery: $(document).ready(function() {    $("#button1").click(function() {      var res = $('#demo').text();      alert(res);    }); }); This is demo text. Get

Read More

How to perform sort using Java?

karthikeya Boyini
karthikeya Boyini
Updated on 11-Mar-2026 151 Views

You can sort an array using sort() method of the Arrays class.Exampleimport java.util.Arrays; public class MainClass {    public static void main(String args[]) throws Exception {       int array[] = { 2, 5, -2, 6, -3, 8, 0, -7, -9, 4 };       Arrays.sort(array);       printArray("Sorted array", array);       int index = Arrays.binarySearch(array, 1);       System.out.println("Didn't find 1 @ " + index);       int newIndex = -index - 1;       array = insertElement(array, 1, newIndex);       printArray("With 1 added", array);    }     ...

Read More
Showing 321–330 of 61,248 articles
« Prev 1 31 32 33 34 35 6125 Next »
Advertisements