Just do a for-loop and return when a non-null object is found.
for (Object obj : objects) {
if (obj != null) {
return obj;
}
}
return null;
More Related Contents:
- Find the function in Java for 1=>5; 2=>4; 3=>3; 4=>2; 5=>1; 6=>7; 7=>6; [closed]
- Java – call void function that print my name
- How to return 2 values from a Java method?
- Purpose of a constructor in Java?
- Nested functions in Java
- functional interface that takes nothing and returns nothing [duplicate]
- functional interface that takes nothing and returns nothing [duplicate]
- How can I create a Java method that accepts a variable number of arguments?
- Passing function as a parameter in java
- What is the equivalent of Regex-replace-with-function-evaluation in Java 7?
- Writing a function inside the main method – Java
- Array of function pointers in Java [duplicate]
- How to clear SharedPreferences during Logout? [duplicate]
- How to get a file’s Media Type (MIME type)?
- Split Java String by New Line
- What is the concept of erasure in generics in Java?
- ConcurrentModificationException for ArrayList [duplicate]
- How to call a stored procedure from Java and JPA
- How can I “intercept” Ctrl+C in a CLI application?
- Printing Runtime exec() OutputStream to console
- Getting “NoSuchMethodError: org.hamcrest.Matcher.describeMismatch” when running test in IntelliJ 10.5
- IText merge documents with acrofields
- JPA/Hibernate Static Metamodel Attributes not Populated — NullPointerException
- JComboBox autocomplete
- JComponents disappearing after calling mouseClicked()
- How to use keystore in Java to store private key?
- How do I make a Java ResultSet available in my jsp? [duplicate]
- deleting folder from java [duplicate]
- How to create a singleton class
- How to force an app icon on Android O? (Prevent the launcher from adapting it)