In the case of Event-driven programming, we pass a reference to a function which will get called when an event occurs. This mechanism is termed as a callback. Java does not support function pointers. So we can not implement the same direction. But using interfaces we can achieve the same very easily.In the example below, we've made a callback when a button is clicked. See the steps −Create an interface ClickEventHandler with a single method handleClick().Create a ClickHandler class which implements this interface ClickEventHandler.Create a Button class which will call ClickHandler when it's click method is called.Test the application.ExampleLive Demo//Step ... Read More
To get the time difference between two timestamps, try to run the following code. Here, we are calculating the total number of hours, minutes and seconds between two timestamps −ExampleLive Demo JavaScript Dates var date1, date2; date1 = new Date( "Jan 1, 2018 11:10:05" ); document.write(""+date1); date2 = new Date( "Jan 1, 2018 08:15:10" ); document.write(""+date2); var res ... Read More
When a method is invoked on a null reference, it throws NullPointerException but in case of the static method, we can make it possible using cast expression. See the example below −ExampleLive Demopublic class Tester { public static void display(){ System.out.println("display"); } private void print() { System.out.println("print"); } public static void main(String[] args) { //Scenario 1: //Calling a method on null reference //causes NullPointerException try { Tester test = null; ... Read More
Use the justify-content-start class in Bootstrap to justify content in the beginning.The justify-content-*-start class is used in Bootstrap to justify content in the beginning on different screen sizes like the following on small, medium, and large screen sizes −You can try to run the following code to implement the justify-content-*-start class −ExampleLive Demo Bootstrap Example Entertainment Bollywood Tollywood Hollywood Bollywood Tollywood Hollywood Bollywood Tollywood Hollywood
To align flex items on small, medium, large and extra large screen size, use the justify-content-*-start class.Let us see first for small screen size − Interface Packages Multithreading In the same way, implement it for medium, large and extra large screen size like the following −justify-content-md-start: Medium Screen size justify-content-lg-start: Large Screen size justify-content-xl-start: Extra Large Screen SizeYou can try to run the following code to align flex items in the start on different screen sizes −ExampleLive Score Bootstrap Example Java Topics Interface Packages Multithreading Interface Packages Multithreading Interface Packages Multithreading
To add top rounded corners to an element, use the rounded-top class in Bootstrap 4.I have taken div as the element −Let us learn how to add top rounded corners to an element −ExampleLive Demo Bootstrap Example .new { width: 80px; height: 80px; background-color: #EE6D1E; margin: 20px; } Rounded Corner We have a rectangle with top rounded corner:
To add a red border to an element, you need to implement the border-danger class.Red border implement danger and you can set danger messages inside it.Implementing the border-danger is quite easy − Red Border Let us see an example to work with the border-danger Bootstrap 4 class −ExampleLive Demo Bootstrap Example .new { width: 120px; height: 120px; margin: 20px; } Rectangle with red border: Red Border
To set a border indicating information, use the border-info class.To implement it − Information Let us see an example to implement the border-info class −ExampleLive Demo Bootstrap Example .one { width: 200px; height: 240px; margin: 40px; } Rectangle with a border indicating information: Information
Use the border-light class in Bootstrap 4, to set a light gray border to an element as shown below light border Style for the demo class is for the element −.demo { width: 150px; height: 220px; margin: 15px; }Learn how to work with the border-light class in Bootstrap −ExampleLive Demo Bootstrap Example .demo { width: 150px; height: 220px; margin: 15px; } Bootstrap 4 light border
Use the border-0 class in Bootstrap 4 to remove all borders from an element in Bootstrap 4 − no border Above, we have the div class to no-border class and this allow us to remove the borders from the element.Let us see an example to implement the border-0 class in Bootstrap −ExampleLive Demo Bootstrap Example .mystyle { width: 120px; height: 100px; margin: 10px; background: maroon; } Rectangle no border
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP