Java instanceof and Its Applications

Ankith Reddy
Updated on 23-Jun-2020 15:25:56

643 Views

instanceof operator is used to check the type of object passed. Following rules explain the usage of instanceof operator in Java.instanceof operator returns true for the object if checked against its class type.instanceof operator returns false for the object if checked against its type which is not in its hierarchy.instanceof operator returns true for the child object if checked against parent object type.instanceof operator returns true for the complete object hierarchy up to the Object class.instanceof operator returns false for the null value.instanceof operator returns false for the parent object if checked against child object type.Following example showcases the above ... Read More

Style Input Fields of a Form with CSS

Smita Kapse
Updated on 23-Jun-2020 15:25:45

383 Views

To style the input field of a form, you can try to run the following code. Style the :ExampleLive Demo                    input {             width: 100%;          }                     Fill the below form,                Subject                    Student                    

Select All Elements with rel=nofollow using CSS

usharani
Updated on 23-Jun-2020 15:25:05

350 Views

Use the [attribute = ”value”] selector to select elements with a specified attribute and value.You can try to run the following code to implement the CSS [attribute="value"] Selector. Here, we have considered the attribute as rel,ExampleLive Demo                    a[rel = nofollow] {             border: 3px solid blue;          }                     Uber's Business Model       Share          Market    

Java 8 Optional Class

Chandu yadav
Updated on 23-Jun-2020 15:24:33

548 Views

Optional is a container object used to contain not-null objects. Optional object is used to represent null with absent value. This class has various utility methods to facilitate code to handle values as 'available' or 'not available' instead of checking null values. It is introduced in Java 8 and is similar to what Optional is in Guava.Class DeclarationFollowing is the declaration for java.util.Optional class −public final class Optional extends ObjectClass MethodSr.No.Method & Description1static Optional empty()Returns an empty Optional instance.2boolean equals(Object obj)Indicates whether some other object is "equal to" this Optional.3Optional filter(PredicateRead More

ListIterator in Java

Arjun Thakur
Updated on 23-Jun-2020 15:23:49

436 Views

The java.util.LinkedList.listIterator(int index) method returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list.DeclarationFollowing is the declaration for java.util.LinkedList.listIterator() methodpublic ListIterator listIterator(int index)Parametersindex − index of the first element to be returned from the list-iteratorReturn ValueThis method returns a ListIterator of the elements in this list (in proper sequence), starting at the specified position in the listExceptionIndexOutOfBoundsException − if the index is out of rangeExampleThe following example shows the usage of java.util.LinkedList.listIterator() method.Example Live Demopackage com.tutorialspoint; import java.util.*; public class LinkedListDemo {    public static void main(String[] args) { ... Read More

Retain Style Values with CSS Keyframes

Ankith Reddy
Updated on 23-Jun-2020 15:23:03

162 Views

To set the elements to retain the style values set by the last keyframe, use the animation-fill-mode property with the backwards value.ExampleLive Demo                    div {             width: 150px;             height: 200px;             position: relative;             background: red;             animation-name: myanim;             animation-duration: 2s;             animation-fill-mode: backwards;          }          @keyframes myanim {             from {left: 0px; background-color: green;}             to {left: 200px; background-color: blue;}          }                        

Set Bottom Tooltip with CSS

seetha
Updated on 23-Jun-2020 15:21:49

777 Views

To set bottom tooltip, use the top CSS property.You can try to run the following code to set bottom tooltip to a text:ExampleLive demo           .mytooltip .mytext {          visibility: hidden;          width: 140px;          background-color: orange;          color: white;          z-index: 1;          top: 100%;          left: 60%;          margin-left: -90px;          text-align: center;          border-radius: 6px;          padding: 5px 0;          position: absolute;       }       .mytooltip {          position: relative;          display: inline-block;          margin-top: 50px;       }       .mytooltip:hover .mytext {          visibility: visible;       }               Keep mouse cursor over me           My Tooltip text          

Check String as Palindrome in Java

Arjun Thakur
Updated on 23-Jun-2020 15:21:47

4K+ Views

A string is Palindrome if position of each character remain same in case even string is reversed.For example 'MADAM' is a palidrome string as position of each character remain same even if string 'MADAM' is reversed.Now in order to identify a string as palindrome or not we can use library method approach and also without library method approach.But if we want to check if "Madam" is palindrome or not , it will show us that it is not a palindrome because of the upper case of first letter.Example - Without library method. Live Demopublic class Palindrome {    public static void ... Read More

Select Elements with Specified Attribute Starting with Value in CSS

Nitya Raut
Updated on 23-Jun-2020 15:20:41

173 Views

Use the [attribute| = ”value”] selector to select elements with the specified attribute starting with a specified value.You can try to run the following code to implement CSS [attribute| = ”value”] Selector,ExampleLive Demo                    [alt |= Tutor] {             border: 5px solid orange;             border-radius: 5px;          }                              

Instance Variable as Final in Java

Arjun Thakur
Updated on 23-Jun-2020 15:20:34

2K+ Views

final is a non-access modifier for Java elements. The final modifier is used for finalizing the implementations of classes, methods, and variables. A final instance variable can be explicitly initialized only once.A final instance variable should be initialized at one of the following occasions −At time of declaration.In constructor.In instance block.Compiler will throw error, it a final variable is not initialized at all using any of the above methods. Following examples showcases example of instance variables as final.Example Live Demopublic class Tester{    final int A = 1;    final int B;{       B = 2;    }   ... Read More

Advertisements