Fendadis John has Published 98 Articles

Java variable declaration best practices

Fendadis John

Fendadis John

Updated on 15-Jun-2020 05:46:54

Following are the best practices while declaring a variable.Variables names should be short or long enough as per the scope. For example, loop counter variable, i is fine whereas employee as a loop variable.Specific words should not be used as equals, compare, data.Use meaningful names which can explain the purpose ... Read More

Data types in Java

Fendadis John

Fendadis John

Updated on 13-Jun-2020 13:40:27

There are two data types available in Java −Primitive Data TypesReference/Object Data TypesPrimitive Data TypesThere are eight primitive data types supported by Java. Primitive data types are predefined by the language and named by a keyword. Let us now look into the eight primitive data types in detail.byteByte data type ... Read More

What is the purpose of a self-executing function in JavaScript?

Fendadis John

Fendadis John

Updated on 12-Jun-2020 12:08:10

The purpose of a self-executing is that those variables declared in the self-executing function are only available inside the self-executing function.Variables declared in the self-executing function are, by default, only available to code within the self-executing function.It is an immediately invoked function expression (IIFE). It is a function, which executes ... Read More

How to set the shape of the border of the top-right corner with JavaScript?

Fendadis John

Fendadis John

Updated on 23-May-2020 10:08:48

To set the shape of the border of the top-right corner in JavaScript, use the borderTopRightRadius property. Set border radius using this property.ExampleYou can try to run the following code to learn how to set the shape of the top-right border with JavaScript.Live Demo           ... Read More

How to convert String to Boolean in JavaScript?

Fendadis John

Fendadis John

Updated on 20-May-2020 08:55:35

You can try to run the following to learn how to convert String to Boolean in JavaScript.ExampleLive Demo           Convert String to Boolean                var myString = "Amit";          document.write("Boolean : " + Boolean(myString));          

What is the role of pageYOffset property?

Fendadis John

Fendadis John

Updated on 19-May-2020 10:59:13

If you want to get the pixels of the document scrolled to from the upper left corner of the window, then use the pageXoffset and pageYoffset property. Use pageYoffset for vertical pixels.ExampleYou can try to run the following code to learn how to work with pageYOffset property in JavaScript.Live Demo ... Read More

Find the largest number in a Java array.

Fendadis John

Fendadis John

Updated on 12-Mar-2020 08:17:46

ExampleFollowing is the required program.Live Demopublic class Tester {    public static int getLargest(int[] a) {       int temp;       //sort the array       for (int i = 0; i < a.length; i++) {          for (int j = i + ... Read More

Java String toLowerCase() method example.

Fendadis John

Fendadis John

Updated on 26-Feb-2020 08:13:49

The toLowerCase() method has two variants. The first variant converts all of the characters in this String to lower case using the rules of the given Locale. This is equivalent to calling toLowerCase(Locale.getDefault()).The second variant takes a locale as an argument to be used while converting into lower case.ExampleLive Demoimport ... Read More

How to compare strings in Java?

Fendadis John

Fendadis John

Updated on 26-Feb-2020 08:11:55

You can compare two Strings in Java using the compareTo() method, equals() method or == operator.The compareTo() method compares two strings. The comparison is based on the Unicode value of each character in the strings. The character sequence represented by this String object is compared lexicographically to the character sequence ... Read More

Java String indexOf() method example.

Fendadis John

Fendadis John

Updated on 26-Feb-2020 08:07:34

The IndexOf() method of the String class accepts a character as a parameter and it returns the index of the first occurrence of the specified character. In case if the String does not contain the specified character then it returns -1.ExampleLive Demoimport java.io.*; public class Test {    public static ... Read More

Previous 1 ... 4 5 6 7 8 ... 10 Next
Advertisements