What do you want to save?
Add Code snippet
New code examples
-
Ruby 2021-09-16 05:00:02
ruby does object exist in array
# Element exists in array object_exists = arr.any? { |elem| elem == desired_value } # Element with property exists in array object_exists = arr.any? { |obj| obj.prop == desired_value } # Type exists in array object_exists = arr.any?(Integer) # Element ... Add solution -
Java 2021-09-16 03:06:02
Java program to insert an element at specific position in an array
import java.util.Scanner; public class InsertElement { public static void main(String[] args) { int number, position, insert; Scanner sc = new Scanner(System.in); System.out.println("Please enter number of elements in array: ... Add solution -
Java 2021-09-14 01:15:01
Java program to print odd and even numbers in an array
import java.util.Scanner; public class EvenOddArray { public static void main(String[] args) { int numbers; Scanner sc = new Scanner(System.in); System.out.print("Please enter elements in array : "); numbe... Add solution -
Javascript 2021-09-13 12:46:02
syntax of reduce in js
const sum = array.reduce((accumulator, element) => { return accumulator + element; }, 0); // An example that will loop through an array adding // each element to an accumulator and returning it // The 0 at the end initializes accumulator to start at ... Add solution -
Other 2021-09-06 08:58:02
length vs length()
length() : In String class we have length() method which is used to return the number of characters in string. Ex : String str = “Hello World”; System.out.println(str.length()); Str.length() will return 11 characters including space. leng... Add solution -
Java 2021-09-06 08:47:01
how to make java list
//Creating arraylist example ArrayList<String> list = new ArrayList<String>(); //Adding objects in arraylist list.add("Mango"); list.add("Banana"); //Change the element (index,"new value") list.set(1... Add solution -
Java 2021-09-01 09:20:03
What is difference between length and length() method in java
length() : In String class we have length() method which is used to return the number of characters in string. Ex : String str = “Hello World”; System.out.println(str.length()); Str.length() will return 11 characters including space. leng... Add solution