V Jyothi has Published 87 Articles

Single dimensional array in Java

V Jyothi

V Jyothi

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

674 Views

Following is a simple example of a single dimensional array.Example Live Demopublic class Tester {    public static void main(String[] args) {       double[] myList = {1.9, 2.9, 3.4, 3.5};       // Print all the array elements       for (double element: myList) {          System.out.print(element + " ");       }    } }Output1.9 2.9 3.4 3.5

Java Runtime Polymorphism with multilevel inheritance

V Jyothi

V Jyothi

Updated on 17-Jun-2020 07:28:52

2K+ Views

Method overriding is an example of runtime polymorphism. In method overriding, a subclass overrides a method with the same signature as that of in its superclass. During compile time, the check is made on the reference type. However, in the runtime, JVM figures out the object type and would run ... Read More

How to perform binary search on an array in java?

V Jyothi

V Jyothi

Updated on 16-Jun-2020 10:17:11

116 Views

The Arrays class of java package provides you a method named binarySearch() using this method you can perform a binary search on an array in Java.ExampleLive Demoimport java.util.Arrays; public class ArrayDemo {    public static void main(String[] args) {       int intArr[] = {30, 20, 5, 12, 55}; ... Read More

How to find the intersection of two arrays in java?

V Jyothi

V Jyothi

Updated on 16-Jun-2020 09:54:49

6K+ Views

To find the intersection of two arrays in java use two loops. The outer loop is to iterate the elements of the first array whereas, the second loop is to iterate the elements of the second array. Within the second loop compare the elements of the two arrays:ExampleLive Demopublic class ... Read More

How to convert Java Array to Iterable?

V Jyothi

V Jyothi

Updated on 16-Jun-2020 08:52:32

8K+ Views

To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream() methods respectively. Then you can get an iterator for these objects using the iterator() method.ExampleLive Demoimport java.util.Arrays; import java.util.Iterator; public class ArrayToIterable {    public static void main(String ... Read More

How do I remove a property from a JavaScript object?

V Jyothi

V Jyothi

Updated on 16-Jun-2020 06:21:09

96 Views

To remove a property from a JavaScript object, use the delete keyword. You can try to run the following code to learn how to remove a propertyExampleLive Demo                          var cricketer = {             name:"Amit",             rank:1,             points: 150          };          delete cricketer.rank;          document.getElementById("demo").innerHTML =             cricketer.name + " has " + cricketer.rank + " rank.";          

Execute a script when the element gets focus in HTML?

V Jyothi

V Jyothi

Updated on 01-Jun-2020 10:41:55

196 Views

Use the onfocus attribute to execute a script when the element gets focus in HTML.ExampleYou can try to run the following code to implement the onfocus attribute −           Enter subject name below,       Subject:                      function display(val) {             document.getElementById(val).style.background = "blue";          }          

How do we display inserted text in HTML?

V Jyothi

V Jyothi

Updated on 30-May-2020 23:00:11

327 Views

Use the tag to display inserted text in HTML. The following are the attributes −AttributeValueDescriptionciteURLDefines a URL to another document which explains why the text was deleted.datetimeYYYYMMDD HH:MM:SSDefines the date and time the text was deleted.ExampleYou can try to run the following code to display inserted text − ... Read More

StringTokenizer class in Java

V Jyothi

V Jyothi

Updated on 05-Mar-2020 12:18:39

362 Views

The StringTokenizer class of the java.util package allows an application to break a string into tokens.This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.Its methods do not distinguish among identifiers, numbers, and quoted strings.This class methods do not even ... Read More

Fibonacci series program in Java using recursion.

V Jyothi

V Jyothi

Updated on 05-Mar-2020 12:16:09

2K+ Views

Following is the required program.ExampleLive Demopublic class Tester {    static int n1 = 0, n2 = 1, n3 = 0;    static void fibbonacci(int count) {       if (count > 0) {          n3 = n1 + n2;          n1 = ... Read More

Advertisements