Tabnine Logo
Arrays.asList
Code IndexAdd Tabnine to your IDE (free)

How to use
asList
method
in
java.util.Arrays

Best Java code snippets using java.util.Arrays.asList (Showing top 20 results out of 217,818)

Refine searchRefine arrow

  • Test.<init>
  • Assert.assertEquals
  • List.add
  • List.size
  • List.addAll
  • List.get
  • Assert.assertTrue
canonical example by Tabnine

private void usingArrayList() {
 ArrayList<String> list = new ArrayList<>(Arrays.asList("cat", "cow", "dog"));
 list.add("fish");
 int size = list.size(); // size = 4
 list.set(size - 1, "horse"); // replacing the last element to "horse"
 String removed = list.remove(1); // removed = "cow"
 String second = list.get(1); // second = "dog"
}
origin: spring-projects/spring-framework

/**
 * Add the specified locales as preferred request locales.
 * @param locales the locales to add
 * @since 4.3.6
 * @see #locale(Locale)
 */
public MockHttpServletRequestBuilder locale(Locale... locales) {
  Assert.notEmpty(locales, "'locales' must not be empty");
  this.locales.addAll(Arrays.asList(locales));
  return this;
}
origin: jenkinsci/jenkins

public ProcStarter cmds(File program, String... args) {
  commands = new ArrayList<String>(args.length+1);
  commands.add(program.getPath());
  commands.addAll(Arrays.asList(args));
  return this;
}
origin: hankcs/HanLP

public void setPenalty(int i, int j, double penalty)
{
  if (penalty_.isEmpty())
  {
    for (int s = 0; s < node_.size(); s++)
    {
      List<Double> penaltys = Arrays.asList(new Double[ysize_]);
      penalty_.add(penaltys);
    }
  }
  penalty_.get(i).set(j, penalty);
}
origin: spring-projects/spring-framework

@Test
public void testGetBeanNamesForTypeWithOverride() throws Exception {
  List<String> names = Arrays.asList(
      BeanFactoryUtils.beanNamesForTypeIncludingAncestors(this.listableBeanFactory, ITestBean.class));
  // includes 2 TestBeans from FactoryBeans (DummyFactory definitions)
  assertEquals(4, names.size());
  assertTrue(names.contains("test"));
  assertTrue(names.contains("test3"));
  assertTrue(names.contains("testFactory1"));
  assertTrue(names.contains("testFactory2"));
}
origin: apache/kafka

private List<String> extractCompactSerializationSplits() {
  List<String> tmpSplits = new ArrayList<>(Arrays.asList(compactSerialization.split("\\.")));
  if (compactSerialization.endsWith("."))
    tmpSplits.add("");
  if (tmpSplits.size() != 3)
    throw new OAuthBearerIllegalTokenException(OAuthBearerValidationResult.newFailure(
        "Unsecured JWS compact serializations must have 3 dot-separated Base64URL-encoded values"));
  return Collections.unmodifiableList(tmpSplits);
}
origin: spring-projects/spring-framework

/**
 * Add resolver that returns a fixed set of media types.
 * @param mediaTypes the media types to use
 */
public void fixedResolver(MediaType... mediaTypes) {
  this.candidates.add(() -> new FixedContentTypeResolver(Arrays.asList(mediaTypes)));
}
origin: google/guava

public SortedMapSubmapTestMapGenerator(
  TestSortedMapGenerator<K, V> delegate, Bound to, Bound from) {
 super(delegate);
 this.to = to;
 this.from = from;
 SortedMap<K, V> emptyMap = delegate.create();
 this.entryComparator = Helpers.entryComparator(emptyMap.comparator());
 // derive values for inclusive filtering from the input samples
 SampleElements<Entry<K, V>> samples = delegate.samples();
 @SuppressWarnings("unchecked") // no elements are inserted into the array
 List<Entry<K, V>> samplesList =
   Arrays.asList(samples.e0(), samples.e1(), samples.e2(), samples.e3(), samples.e4());
 Collections.sort(samplesList, entryComparator);
 this.firstInclusive = samplesList.get(0).getKey();
 this.lastInclusive = samplesList.get(samplesList.size() - 1).getKey();
}
origin: ReactiveX/RxJava

  @Test
  public void sameSizeReverse() throws Exception {
    MergerBiFunction<Integer> merger = new MergerBiFunction<Integer>(new Comparator<Integer>() {
      @Override
      public int compare(Integer o1, Integer o2) {
        return o1.compareTo(o2);
      }
    });
    List<Integer> list = merger.apply(Arrays.asList(3, 5), Arrays.asList(2, 4));

    assertEquals(Arrays.asList(2, 3, 4, 5), list);
  }
}
origin: square/okhttp

public void assertResponseCookies(String... cookies) {
 List<Cookie> actualCookies = takeResponseCookies();
 List<String> actualCookieStrings = new ArrayList<>();
 for (Cookie cookie : actualCookies) {
  actualCookieStrings.add(cookie.toString());
 }
 assertEquals(Arrays.asList(cookies), actualCookieStrings);
}
origin: spring-projects/spring-framework

@Test
public void collectionToObjectInteraction() throws Exception {
  List<List<String>> list = new ArrayList<>();
  list.add(Arrays.asList("9", "12"));
  list.add(Arrays.asList("37", "23"));
  conversionService.addConverter(new CollectionToObjectConverter(conversionService));
  assertTrue(conversionService.canConvert(List.class, List.class));
  assertSame(list, conversionService.convert(list, List.class));
}
origin: ReactiveX/RxJava

@SuppressWarnings("unchecked")
@Test
public void dispose() {
  PublishProcessor<Integer> pp = PublishProcessor.create();
  TestObserver<Object> to = Maybe.zip(Arrays.asList(pp.singleElement(), pp.singleElement()), addString)
  .test();
  assertTrue(pp.hasSubscribers());
  to.cancel();
  assertFalse(pp.hasSubscribers());
}
origin: spring-projects/spring-framework

@Test
public void testHierarchicalNamesForAnnotationWithNoMatch() throws Exception {
  List<String> names = Arrays.asList(
      BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.listableBeanFactory, Override.class));
  assertEquals(0, names.size());
}
origin: neo4j/neo4j

/**
 * @param allowHeapAllocation whether or not to include heap allocation as an alternative.
 * @param additional other means of allocation to try after the standard off/on heap alternatives.
 * @return an array of {@link NumberArrayFactory} with the desired alternatives.
 */
static NumberArrayFactory[] allocationAlternatives( boolean allowHeapAllocation, NumberArrayFactory... additional )
{
  List<NumberArrayFactory> result = new ArrayList<>( Collections.singletonList( OFF_HEAP ) );
  if ( allowHeapAllocation )
  {
    result.add( HEAP );
  }
  result.addAll( asList( additional ) );
  return result.toArray( new NumberArrayFactory[result.size()] );
}
origin: org.mockito/mockito-core

@Override
public Object[] getConstructorArgs() {
  if (outerClassInstance == null) {
    return constructorArgs;
  }
  List<Object> resultArgs = new ArrayList<Object>(constructorArgs.length + 1);
  resultArgs.add(outerClassInstance);
  resultArgs.addAll(Arrays.asList(constructorArgs));
  return resultArgs.toArray(new Object[constructorArgs.length + 1]);
}
origin: apache/storm

private static List<Dependency> parseArtifactArgs(String artifactArgs) {
  List<String> artifacts = Arrays.asList(artifactArgs.split(","));
  List<Dependency> dependencies = new ArrayList<>(artifacts.size());
  for (String artifactOpt : artifacts) {
    if (artifactOpt.trim().isEmpty()) {
      continue;
    }
    dependencies.add(AetherUtils.parseDependency(artifactOpt));
  }
  return dependencies;
}
origin: google/guava

public void testIterator() {
 List<E> iteratorElements = new ArrayList<E>();
 for (E element : collection) { // uses iterator()
  iteratorElements.add(element);
 }
 Helpers.assertEqualIgnoringOrder(Arrays.asList(createSamplesArray()), iteratorElements);
}
origin: google/guava

public void testPartition_3_2() {
 List<Integer> source = asList(1, 2, 3);
 List<List<Integer>> partitions = Lists.partition(source, 2);
 assertEquals(2, partitions.size());
 assertEquals(asList(1, 2), partitions.get(0));
 assertEquals(asList(3), partitions.get(1));
}
origin: ReactiveX/RxJava

@Test
public void secondEmpty() throws Exception {
  MergerBiFunction<Integer> merger = new MergerBiFunction<Integer>(new Comparator<Integer>() {
    @Override
    public int compare(Integer o1, Integer o2) {
      return o1.compareTo(o2);
    }
  });
  List<Integer> list = merger.apply(Arrays.asList(2, 4), Collections.<Integer>emptyList());
  assertEquals(Arrays.asList(2, 4), list);
}
origin: spring-projects/spring-framework

@Override
public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors) {
  if (!ObjectUtils.isEmpty(interceptors)) {
    this.interceptors.addAll(Arrays.asList(interceptors));
  }
  return this;
}
java.utilArraysasList

Javadoc

Returns a List of the objects in the specified array. The size of the List cannot be modified, i.e. adding and removing are unsupported, but the elements can be set. Setting an element modifies the underlying array.

Popular methods of Arrays

  • toString
    Returns a string representation of the contents of the specified array. The string representation co
  • equals
    Returns true if the two specified arrays of booleans areequal to one another. Two arrays are conside
  • sort
    Sorts the specified range of the array into ascending order. The range to be sorted extends from the
  • copyOf
    Copies the specified array, truncating or padding with false (if necessary) so the copy has the spec
  • fill
    Assigns the specified boolean value to each element of the specified array of booleans.
  • stream
  • hashCode
    Returns a hash code based on the contents of the specified array. For any two boolean arrays a and
  • copyOfRange
    Copies the specified range of the specified array into a new array. The initial index of the range (
  • binarySearch
    Searches the specified array of shorts for the specified value using the binary search algorithm. Th
  • deepEquals
    Returns true if the two specified arrays are deeply equal to one another. Unlike the #equals(Object[
  • deepToString
  • deepHashCode
    Returns a hash code based on the "deep contents" of the specified array. If the array contains other
  • deepToString,
  • deepHashCode,
  • setAll,
  • parallelSort,
  • parallelSetAll,
  • spliterator,
  • checkBinarySearchBounds,
  • checkOffsetAndCount,
  • checkStartAndEnd

Popular in Java

  • Making http requests using okhttp
  • getSupportFragmentManager (FragmentActivity)
  • runOnUiThread (Activity)
  • onCreateOptionsMenu (Activity)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now