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
-
Economics & Finance
Articles by AmitDiwan
Page 625 of 840
How to create a responsive website with Bootstrap 4?
To create a responsive website with Bootstrap 4, the code is as follows −Example Bootstrap 4 Website Example body{ height: 100vh; } Website ⇅ Logo Link Link Link Headline 1 Published in January Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias perferendis hic quas praesentium quod totam atque dignissimos nobis numquam consequuntur? Headline 2 Published in march Lorem ipsum dolor sit amet consectetur adipisicing elit. Aliquam doloribus incidunt voluptatum labore dolorem voluptate iure dicta, dolorum quis maiores. Copyright © Website OutputThe above code will produce the following output −On resizing the screen −
Read MoreJava Concurrency – sleep() method
The sleep functionThis sleep function is used to ensure that the currently executing thread goes to sleep for a specific amount of milliseconds which is passed as a parameter to the function. The thread stops executing for that number of milliseconds.Let us see an exampleExampleimport java.lang.*; public class Demo implements Runnable{ Thread my_t; public void run(){ for (int i = 0; i < 3; i++){ System.out.println(Thread.currentThread().getName()+ " " + i); try{ Thread.sleep(100); } ...
Read MoreJava Lambda Expression with Collections
Sorting the elements of a list using lambda expression −Exampleimport java.util.*; public class Demo{ public static void main(String[] args){ ArrayList my_arr = new ArrayList(); my_arr.add(190); my_arr.add(267); my_arr.add(12); my_arr.add(0); System.out.println("Before sorting, elements in the array list are : " + my_arr); Collections.sort(my_arr, (o1, o2) -> (o1 > o2) ? -1 : (o1 < o2) ? 1 : 0); System.out.println("After sorting, elements in the array list are : " + my_arr); } }OutputBefore sorting, elements in ...
Read MoreJava Numeric Promotion in Conditional Expression
The conditional operator (? :) leverages the output of one value (which is a bool) to decide which expression has to be evaluated next. Let us see an example −Exampleimport java.io.*; public class Demo{ public static void main (String[] args){ Object my_obj = true ? new Integer(91) : new Float(89); System.out.println(my_obj); } }Output91.0A class named Demo contains the main function. Here, an object instance is defined and if it is true, an integer value is displayed otherwise a float value is displayed. Next, they are printed on the console.When promotional expression is ...
Read MorePascal's Triangle in C++
Pascal’s triangle is an array of binomial coefficients. The top row is numbered as n=0, and in each row are numbered from the left beginning with k = 0. Each number is found by adding two numbers which are residing in the previous row and exactly top of the current cell. It is also being formed by finding (𝑛𝑘) for row number n and column number k.Suppose the input is 10, then the output will be like − 1 1 1 ...
Read MorejQuery dequeue() with Examples
The dequeue() method in jQuery is used to remove the next function from the queue and then execute the function.SyntaxThe syntax is as follows −$(selector).dequeue(queue)Above, the queue is the name of the queue.ExampleLet us now see an example to implement the jQuery dequeue() method − $(document).ready(function(){ $("button").click(function(){ var div = $("div"); div.animate({height: 250}, "slow"); div.animate({left: "+=200", top: "+=100" }, "slow"); div.queue(function(){ div.dequeue(); }); ...
Read MorejQuery hide() with Examples
The hide() method in jQuery is used to hide selected elements.SyntaxThe syntax is as follows −$(selector).hide(speed, easing, callback)Above, the parameter speed is the speed of the hide effect, whereas easing is the speed of the element in different points of the animation. The callback function is a function that executes after hide() method completes.ExampleLet us now see an example to implement the jQuery hide() method − $(document).ready(function(){ $(".btnhide").click(function(){ $("p").hide(); }); $(".btnshow").click(function(){ $("p").show(); }); }); ...
Read MorejQuery data() with Examples
The data() method in jQuery is used to attach data to or gets data from selected elements.SyntaxThe syntax is as follows −$(selector).data(name) $(selector).data(name, value)Above, the name is the name of data to retrieve for the 1st syntax.For the 2nd syntax, the name is the name of data to set, whereas value is the value of data to set.ExampleLet us now see an example to implement the jQuery data() method − $(document).ready(function(){ $(".button1").click(function(){ $("div").data("student", "Jack Sparrow"); alert("Student Name = " +$("div").data("student")); }); ...
Read MorejQuery Traversing Siblings
With jQuery, you can easily find siblings of an element using the following methods: next(), nextAll(), prev(), prevAll(), siblings(), etc. Let us see some of them traverse siblings−next() methodThe next() method is used to return the next sibling element of the selected element. Let us see an example−Example div { width:600px; } .demo * { display: block; border: 2px solid orange; color: blue; padding: 10px; margin: 10px; } $(document).ready(function(){ $("h3").next().css({"color": "gray", "border": "3px dashed blue"}); }); parent sibling sibling ...
Read MorejQuery Misc param() Method
The param() method in jQuery is used to create a serialized representation of an array or object.SyntaxThe syntax is as follows −$.param(obj, val)Above, obj is the object to serialize, whereas Val specifies whether or not to use the traditional style of param serialization.ExampleLet us now see an example to implement the jQuery param() method− $(document).ready(function(){ ob = new Object(); ob.stdid = "S01"; ob.roll = 3; $("button").click(function(){ $("p").text($.param(ob)); }); }); Student Details Serialized Representation OutputThis will produce the following output−Click on the button to get serialized representation−
Read More