What do you want to save?
Add Code snippet
New code examples
-
Java 2022-03-27 21:35:04
Sort string array in case insensitive order and case sensitive order java
import java.util.Arrays; public class SortStringArrayDemo { public static void main(String[] args) { String[] fruits = new String[5]; fruits[0] = "Mango"; fruits[1] = "cherries"; fruits[2] = "Apple&q... Add solution -
TypeScript 2022-03-27 17:05:06
use of slice and splice add elements array
function frankenSplice(arr1, arr2, n) { // Create a copy of arr2. let combinedArrays = arr2.slice() // [4, 5, 6] // Insert all the elements of arr1 into arr2 beginning // at the index specified by n. We're using the spread /... Add solution -
Other 2022-02-03 11:36:54
maximum number from Array
---without sort method--- public static int maxValue( int[] n ) { int max = Integer.MIN_VALUE; for(int each: n) if(each > max) max = each; return max; ---with sort method--- public static int maxValue( int[] n ) { Arrays.sort( n ); return... Add solution -
Java 2022-02-02 12:10:52
java overloading
Overloading mean same method name and different parameter, it can happen in same class. it's a feature that allows us to have more than one method with same name. Example: sort method of Arrays class Arrays.sort(int[] arr) Arrays.sort(String[] arr) ...... Add solution -
Other 2022-02-02 04:47:50
int[] -> Integer[] or List<Integer>
int[] data = {1,2,3,4,5,6,7,8,9,10}; // To boxed array Integer[] what = Arrays.stream( data ).boxed().toArray( Integer[]::new ); Integer[] ever = IntStream.of( data ).boxed().toArray( Integer[]::new ); // To boxed list List<Integer> you = Arrays.... Add solution -
Java 2021-11-20 06:00:16
calculating the percentile in java
public static long[] percentiles(long[] latencies, double... percentiles) { Arrays.sort(latencies, 0, latencies.length); long[] values = new long[percentiles.length]; for (int i = 0; i < percentiles.length; i++) { int index = (int) ... Add solution -
Java 2021-11-17 21:37:15
create stream from array java
// import java.util.Arrays; // import java.util.stream.Stream; String[] array = {"a", "b", "c", "d", "e"}; //Arrays.stream Stream<String> stream1 = Arrays.stream(array); stream1.forEach(x -> Sys... Add solution
Best helpers
Ranking is empty