Arjun Thakur has Published 1109 Articles

Add a background color to the form input with CSS

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 15:29:53

7K+ Views

To add background color to the form input, use the background-color property.You can try to run the following code to implement the background color property to formExampleLive Demo                    input[type=text] {             width: 100%;             padding: 10px 15px;             margin: 5px 0;             box-sizing: border-box;             background-color: gray;          }                     Fill the below form,                Subject                    Student                    

ListIterator in Java

Arjun Thakur

Arjun Thakur

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

296 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 ... Read More

Java program to check string as palindrome

Arjun Thakur

Arjun Thakur

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

3K+ 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 ... Read More

Instance variable as final in Java

Arjun Thakur

Arjun Thakur

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

1K+ 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 ... Read More

Iterator vs forEach in Java

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 15:12:22

2K+ Views

Collections can be iterated easily using two approaches.Using for-Each loop − Use a foreach loop and access the array using object.Using Iterator − Use a foreach loop and access the array using object.DifferencesConcurrentModificationException − Using for-Each loop, if an object is modified, then ConcurrentModificationException can occur. Using iterator, this problem ... Read More

How to create a responsive image gallery with CSS

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 15:10:00

468 Views

To create a responsive image gallery with CSS, you can try to run the following codeExampleLive Demo                    div.myGallery {             border: 2px solid orange;          }          div.myGallery:hover ... Read More

Infinity or exception in Java when divide by 0?

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 15:00:54

257 Views

Consider the following code snippet where we divide a number by 0.Example Live Demopublic class Tester{    public static void main(String[] args) {       double d = 100;       System.out.println(d/0);    } }OutputInfinityNow consider the following code snippet.Example Live Demopublic class Tester{    public static void main(String[] args) ... Read More

How to prevent Serialization to break a Singleton Class Pattern?

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 14:38:06

492 Views

A Singleton pattern states that a class can have a single instance and multiple instances are not permitted to be created. For this purpose, we make the constructor of the class a private and return a instance via a static method. But using serialization, we can still create multiple instance ... Read More

How do you declare, initialize and access jagged arrays in C#?

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 14:18:11

121 Views

Declare Jagged ArrayA Jagged array is an array of arrays. You can declare a jagged array named scores of type int as −int [][] points;Initialize Jagged ArrayLet us now see how to initialize it.int[][] points = new int[][]{new int[]{10, 5}, new int[]{30, 40}, new int[]{70, 80}, new int[]{ 60, 70 ... Read More

How to select a random element from a C# list?

Arjun Thakur

Arjun Thakur

Updated on 23-Jun-2020 14:12:45

39K+ Views

Firstly, set a list in C#.var list = new List{ "one", "two", "three", "four"};Now get the count of the elements and display randomly.int index = random.Next(list.Count); Console.WriteLine(list[index]);To select a random element from a list in C#, try to run the following code −Example Live Demousing System; using System.Collections.Generic; namespace Demo { ... Read More

Advertisements