V Jyothi has Published 82 Articles

Single dimensional array in Java

V Jyothi

V Jyothi

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

725 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

How to perform binary search on an array in java?

V Jyothi

V Jyothi

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

129 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

7K+ 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

119 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

211 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";          }          

StringTokenizer class in Java

V Jyothi

V Jyothi

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

413 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

How to format numbers to strings in Python?

V Jyothi

V Jyothi

Updated on 05-Mar-2020 10:54:42

523 Views

You can format a floating number to a fixed width in Python using the format function on the string. examplenums = [0.555555555555, 1, 12.0542184, 5589.6654753] for x in nums:    print("{:10.4f}".format(x))OutputThis will give the output −0.5556 1.0000 12.0542 5589.6655ExampleUsing the same function, you can also format integers −nums = [5, 20, ... Read More

How to loop through multiple lists using Python?

V Jyothi

V Jyothi

Updated on 05-Mar-2020 08:06:15

516 Views

The most straightforward way seems to use an external iterator to keep track. Note that this answer considers that you're looping on same sized lists. examplea = [10, 12, 14, 16, 18] b = [10, 8, 6, 4, 2] for i in range(len(a)):    print(a[i] + b[i])OutputThis will give the ... Read More

Advertisements