Codota Logo
Snippets.flattenDepth
Code IndexAdd Codota to your IDE (free)

How to use
flattenDepth
method
in
snippets.Snippets

Best Java code snippets using snippets.Snippets.flattenDepth (Showing top 2 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
origin: biezhi/30-seconds-of-java8

/**
 * Flattens an array up to the specified depth.
 *
 * @param elements input array
 * @param depth    depth to which to flatten array
 * @return flattened array
 */
public static Object[] flattenDepth(Object[] elements, int depth) {
  if (depth == 0) {
    return elements;
  }
  return Arrays.stream(elements)
      .flatMap(el -> el instanceof Object[]
          ? Arrays.stream(flattenDepth((Object[]) el, depth - 1))
          : Arrays.stream(new Object[]{el})
      ).toArray();
}
origin: shekhargulati/30-seconds-of-java

/**
 * Flattens an array up to the specified depth.
 *
 * @param elements input array
 * @param depth    depth to which to flatten array
 * @return flattened array
 */
public static Object[] flattenDepth(Object[] elements, int depth) {
  if (depth == 0) {
    return elements;
  }
  return Arrays.stream(elements)
      .flatMap(el -> el instanceof Object[]
          ? Arrays.stream(flattenDepth((Object[]) el, depth - 1))
          : Arrays.stream(new Object[]{el})
      ).toArray();
}
snippetsSnippetsflattenDepth

Javadoc

Flattens an array up to the specified depth.

Popular methods of Snippets

  • anagrams
  • capitalize
  • deepFlatten
    Deep flattens an array.
  • gcd
    Calculates the greatest common denominator (gcd) of an array of numbers
  • getAllInterfaces
  • indexOf
    Find index of element in the array. Return -1 in case element does not exist. Uses IntStream.range(
  • join
  • lastIndexOf
    Find last index of element in the array. Return -1 in case element does not exist. Uses IntStream.it

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • putExtra (Intent)
  • getExternalFilesDir (Context)
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • ConcurrentHashMap (java.util.concurrent)
    A hash table supporting full concurrency of retrievals and adjustable expected concurrency for updat
  • Notification (javax.management)
  • Reference (javax.naming)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now