Set Navigation Bar to Stay at the Top with CSS

Chandu yadav
Updated on 23-Jun-2020 14:55:13

264 Views

To set the navigation bar at top, use position: fixed property, with top property.You can try to run the following code to implement a menu that stays on the top, ExampleLive Demo                    ul {             list-style-type: none;             position: fixed;             top: 0;             width: 100%;          }          li {             float: left;           ... Read More

Add Link Dividers in a Navigation Bar with CSS

George John
Updated on 23-Jun-2020 14:51:27

2K+ Views

To add link dividers in a Navigation Bar, use the border-right property for the element.ExampleLive Demo                    ul {             list-style-type: none;             margin: 0;             padding: 0;          }          li {             float: left;             border-right: 1px solid white;          }          li a {             display: block;             padding: 8px;             background-color: orange;          }          li:last-child {             border-right: none;          }                              Home          News          Contact          About          

Float List Items to the Right with CSS

Daniol Thomas
Updated on 23-Jun-2020 14:50:35

3K+ Views

To float the list items to the right, use float: right property in CSS. You can try to run the following code to implement it,ExampleLive Demo                    ul {             list-style-type: none;             margin: 0;             padding: 0;          }          li {             float: left;          }          li a {             display: block;             padding: 8px;             background-color: orange;          }                              Home          News          Contact          About          

Use Enums in Python Classes

Arnab Chakraborty
Updated on 23-Jun-2020 14:47:21

274 Views

There is a module name "enum" in python with the hep of which enum is used in python.#import enum import enum # use enum in class class Car(enum.Enum):    suzuki = 1    Hyundai = 2    Dezire = 3 print ("All the enum values are : ") for c in (Car):    print(c)

Sort an Array in C# in Descending Order

karthikeya Boyini
Updated on 23-Jun-2020 14:46:40

5K+ Views

The following is the unsorted array.int[] list = {98, 23, 97, 36, 77};Now first use the Sort() method to sort the array.Array.Reverse(list);Use the Reverse() method that would eventually give you a sorted array in descending order.Array.Reverse(list);You can try to run the following code to to sort an array in descending order.Example Live Demousing System; namespace Demo {    public class MyApplication {       public static void Main(string[] args) {          int[] list = {98, 23, 97, 36, 77};          Console.WriteLine("Original Unsorted List");          foreach (int i in list) {   ... Read More

Match All Occurrences of a Regex in Java

Arnab Chakraborty
Updated on 23-Jun-2020 14:46:06

283 Views

public class RegexOccur {    public static void main(String args[]) {       String str = "java is fun so learn java";       String findStr = "java";       int lastIndex = 0;       int count = 0;       while(lastIndex != -1) {          lastIndex = str.indexOf(findStr,lastIndex);          if(lastIndex != -1) {             count ++;             lastIndex += findStr.length();          }       }       System.out.println(count);    } }Output2

Use Multi-Dimensional Arrays in C#

karthikeya Boyini
Updated on 23-Jun-2020 14:45:08

215 Views

C# allows multidimensional arrays. Multi-dimensional arrays are also called rectangular array. Declare a 2-dimensional array of strings as.string [, ] names;A 2-dimensional array can be thought of as a table, which has x number of rows and y number of columns.Multidimensional arrays may be initialized by specifying bracketed values for each row. The following array is with 4 rows and each row has 4 columns.int [, ] a = new int [4, 4] {    {0, 1, 2, 3} , /* initializers for row indexed by 0 */    {4, 5, 6, 7} , /* initializers for row indexed by ... Read More

Replace Backward Slash from a String

Malhar Lathkar
Updated on 23-Jun-2020 14:44:01

676 Views

In Python it does give the desired result>>> var  = "aaa\bbb\ccc and ddd\eee" >>> var.split('\') ['aaa', 'bbb', 'ccc and ddd', 'eee']

Prevent Reflection from Breaking a Singleton Class Pattern

Chandu yadav
Updated on 23-Jun-2020 14:43:37

906 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 reflection, we can still create multiple instance of a class by modifying the constructor scope. See the example below −Example - Breaking Singleton Live Demoimport java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class Tester {    public static void main(String[] args) throws    InstantiationException, IllegalAccessException,    IllegalArgumentException, InvocationTargetException{       A a = A.getInstance();     ... Read More

Sort Two-Dimensional Array in C#

karthikeya Boyini
Updated on 23-Jun-2020 14:41:25

2K+ Views

To sort a two-dimensional array in C#, in a nested for loop, add another for loop to check the following condition.Examplefor (int k = 0; k < j; k++) {    if (arr[i, k] > arr[i, k + 1]) {       int myTemp = arr[i, k];       arr[i, k] = arr[i, k + 1];       arr[i, k + 1] = myTemp;    } }Till the outer loop loops through, use the GetLength() method as shown below. This is done to sort the array.Examplefor (int i = 0; i < arr.GetLength(0); i++) {    for ... Read More

Advertisements