Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
How to capture divide by zero exception in Java?
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 MoreHow to call a JavaScript function from an onClick event?
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 MoreHow to call a JavaScript function from an onmouseover event?
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 MoreWhat does language attribute do in <script> tag in Javascript?
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 MoreWhat is the difference between “lang” and “type” attributes in a script tag?
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 MoreWhat is the difference between System.out.println() and System.out.print() in Java?
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 MoreHow to get the input value of the first matched element using jQuery?
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 MoreHow can I get the selected value of a drop-down list with jQuery?
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 MoreHow to get the value of div content using jQuery?
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 MoreHow to perform sort using Java?
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