Skip to main content
@RAnders00: commons-lang2 is built for a end-of-life java (1.2) release, change to Java 6 commons-lang3
Source Link
Intracer
  • 3.1k
  • 1
  • 19
  • 13

You can use ArrayUtils.containsArrayUtils.contains from Apache Commons LangApache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)public static boolean contains(Object[] array, Object objectToFind)

Note that this method returns false if the passed array is null.

There are also methods available for primitive arrays of all kinds.

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Note that this method returns false if the passed array is null.

There are also methods available for primitive arrays of all kinds.

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 
deleted 30 characters in body
Source Link
August
  • 12.6k
  • 3
  • 38
  • 53

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 
added 175 characters in body
Source Link
Joshua Pinter
  • 47.9k
  • 23
  • 261
  • 258

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

You can use ArrayUtils.contains from Apache Commons Lang

public static boolean contains(Object[] array, Object objectToFind)

Example:

String[] fieldsToInclude = { "id", "name", "location" }; if ( ArrayUtils.contains( fieldsToInclude, "id" ) ) { // Do some stuff. } 
fixed link
Source Link
Slava Semushin
  • 15.2k
  • 7
  • 56
  • 69
Loading
Source Link
Intracer
  • 3.1k
  • 1
  • 19
  • 13
Loading