George John has Published 1167 Articles

How to swap or exchange objects in Java?

George John

George John

Updated on 23-Jun-2020 15:05:26

324 Views

Java uses call by value while passing parameters to a function. To swap objects, we need to use their wrappers. See the example below −Example Live Demopublic class Tester{    public static void main(String[] args) {       A a = new A();       A b = new ... Read More

How to add link dividers in a Navigation Bar with CSS

George John

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          

How to prevent Cloning to break a Singleton Class Pattern?

George John

George John

Updated on 23-Jun-2020 14:27:50

1K+ 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 cloning, we can still create multiple instance ... Read More

How to split a string using regular expressions in C#?

George John

George John

Updated on 23-Jun-2020 14:24:54

964 Views

To split a string suing regular expression, use the Regex.split.Let’s say our string is −string str = "Hello\rWorld";Now use Regex.split to split the string as shown below −tring[] res = Regex.Split(str, "\r");The following is the complete code to split a string using Regular Expression in C#.Example Live Demousing System; using System.Text.RegularExpressions; ... Read More

How to use the ToString() method of array in C#?

George John

George John

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

305 Views

The ToString() method returns a string that represents the current object.In the below example, we have used the ToString() method with another Array class method.arr.GetLowerBound(0).ToString()Example Live Demousing System; using System.Collections.Generic; using System.Linq; using System.Text; namespace lower {    class Program {       static void Main(string[] args) {     ... Read More

What are the differences between a pointer variable and a reference variable in C++?

George John

George John

Updated on 23-Jun-2020 13:49:38

972 Views

ReferencesWhen a variable is declared as a reference, it becomes an alternative name for an existing variable.Syntax Type &newname = existing name;InitializationType &pointer; pointer = variable name;PointersPointers are used to store the address of a variable.SyntaxType *pointer;InitializationType *pointer; pointer = variable name;The main differences between references and pointers are -References ... Read More

How to deal with Internet Explorer and addEventListener problem "Object doesn't support this property or method" in JavaScript?

George John

George John

Updated on 23-Jun-2020 13:05:00

1K+ Views

To deal with “Object doesn’t support this property or method” issue in JavaScript, while using events and Internet Explorer, update your code with this −Example                      ...     You can also use attachEvent in IE to solve this issue ... Read More

How to set the minimum number of lines for an element that must be visible at the top of a page in JavaScript?

George John

George John

Updated on 23-Jun-2020 13:02:06

84 Views

Use the orphans property in JavaScript to set the minimum number of lines for an element that must be visible at the top of a page. You can try to run the following code to learn how to implement orphans property −document.getElementById("p").style.orphansThis is how you can return the orphans property −var ... Read More

How do I clear the usage of setInterval()?

George John

George John

Updated on 23-Jun-2020 12:58:39

124 Views

The setInterval() method is used evaluate an expression at specified intervals. This function calls function after every duration milliseconds. This goes for unlimited times. Let’s see an example −It triggers alert(‘Hello’) after every 2000 milliseconds, not only once.setInterval(function() { alert('Hello');}, 2000);To clear the usage of setInterval(), use the window.clearInterval() and set ... Read More

How to use the GetLongLength method of array class in C#?

George John

George John

Updated on 23-Jun-2020 12:47:19

247 Views

The GetLongLength method in C# gets a 64-bit integer that represents the number of elements in the specified dimension of the Array.First, set the array.long[, ] arr2= new long[15, 35];For a specified dimension of the array, set the index in the GetLongMethod() method like −long len2 = arr2.GetLongLength(0);Let us see ... Read More

Advertisements