MCPcopy Create free account

hub / github.com/bobocode-projects/java-fundamentals-exercises / functions

Functions921 in github.com/bobocode-projects/java-fundamentals-exercises

↓ 1 callersMethodlongSumOperation
Returns a {@link LongBinaryOperator} sum operation. @return binary sum operation
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:107
↓ 1 callersMethodnMultiplyFunctionSupplier
Receives int parameter n, and returns a {@link Supplier} that supplies {@link IntUnaryOperator} that is a function f(x) = n x @param n a multiplier @
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:127
↓ 1 callersMethodnewNode
(int element)
2-0-data-structures-and-algorithms/2-2-2-stack/src/test/java/com/bobocode/cs/LinkedStackTest.java:364
↓ 1 callersMethodnewThreadRunnableConsumer
Returns a {@link Consumer} that accepts {@link Runnable} as a parameter and runs in a new thread. @return a runnable consumer
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:156
↓ 1 callersMethodof
(T... elements)
2-0-data-structures-and-algorithms/2-2-6-binary-search-tree/src/main/java/com/bobocode/cs/RecursiveBinarySearchTree.java:21
↓ 1 callersMethodof
Creates and returns an instance of {@link ArrayList} with provided elements @param elements to add @return new instance
2-0-data-structures-and-algorithms/2-2-5-array-list/src/main/java/com/bobocode/cs/ArrayList.java:40
↓ 1 callersMethodpairOf
Creates two new {@link Node} objects using provided firstElement and secondElement, and create a connection between those two elements so the first no
2-0-data-structures-and-algorithms/2-2-1-node/src/main/java/com/bobobode/cs/Nodes.java:48
↓ 1 callersMethodpartitionMaleAccounts
Returns a map that separates all accounts into two lists - male and female. Map has two keys {@code true} indicates male list, and {@code false} indic
5-0-functional-programming/5-2-1-crazy-streams/src/main/java/com/bobocode/fp/CrazyStreams.java:52
↓ 1 callersMethodprintARandomNumberUsingIntegerSupplier
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacesExamples.java:23
↓ 1 callersMethodprintAbsUsingMethodReference
(int a)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodReferenceExamples.java:17
↓ 1 callersMethodprintAccount
An if statement is a classic example of imperative check
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalImperativeVsDeclarativeCheck.java:20
↓ 1 callersMethodprintAccount
(Account account)
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalSearchByEmailExample.java:42
↓ 1 callersMethodprintAccountEmails
StreamMapping elements, method map() receives a @{@link java.util.function.Function}. This function transforms(maps) each element of the stream into a
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamMapping.java:28
↓ 1 callersMethodprintAccountFirstNamesByItsBirthdaysMonth
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:51
↓ 1 callersMethodprintAccountOrDefault
or add a default value. Now you're safely trying to get an account instance, because in case it's null you'll get a default value
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalExamples.java:45
↓ 1 callersMethodprintAccountOrRandomLazily
The version with {@link Supplier} should be used in case getting default value requires additional resources. In this case default instance will be on
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalExamples.java:54
↓ 1 callersMethodprintAccountUsingRightApproach
The right way is to pass a consumer that will be used in case {@link Optional} value is not empty
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalExamples.java:37
↓ 1 callersMethodprintAccountUsingWrongApproach
It is not correct to process to process {@link Optional} values in the old imperative way, as it is shown below
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalExamples.java:27
↓ 1 callersMethodprintAccountWithMaxBalanceDeclaratively
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/ImperativeVsDeclarativeMax.java:18
↓ 1 callersMethodprintAccountWithMaxBalanceImperatively
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/ImperativeVsDeclarativeMax.java:26
↓ 1 callersMethodprintAccountsByItsBirthdaysMonth
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:44
↓ 1 callersMethodprintAccountsThatHaveGoogleEmail
To filter accounts we use an instance of @{@link Predicate} that checks if an email is gmail based @param accounts
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamFiltering.java:21
↓ 1 callersMethodprintAccountsUsingLambda
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaAndMethodReference.java:20
↓ 1 callersMethodprintAccountsUsingMethodReference
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaAndMethodReference.java:24
↓ 1 callersMethodprintAllEmails
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamWhileExample.java:17
↓ 1 callersMethodprintAllEmailsWhileGmail
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamWhileExample.java:24
↓ 1 callersMethodprintAllEmailsWhileNotGmail
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamWhileExample.java:32
↓ 1 callersMethodprintAllGmailAccounts
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:34
↓ 1 callersMethodprintBalanceOfFirstGoogleAccount
An example, when you process a stream and find an optional element, with an relation that can be null
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalMapping.java:49
↓ 1 callersMethodprintBalanceStatistic
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamAdditionalFeatures.java:47
↓ 1 callersMethodprintBalanceUsingNullCheck
Hierarchical relation with potential null value, like an account that can be null, has a balance field that also can be null
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalMapping.java:30
↓ 1 callersMethodprintBalanceUsingOptionalMapping
When you want to access a nullable value of account, you can use method map(), that receives a mapper which transform your nullable value into an opti
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalMapping.java:42
↓ 1 callersMethodprintCharacterCounts
()
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamMapping.java:35
↓ 1 callersMethodprintCommaSeparatedNames
Please always use joining() method to avoid performance issues when concatenating {@link String}
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:69
↓ 1 callersMethodprintCreditBalanceOfFirstGoogleAccount
When you use map() it wraps a value within Optional container, and if that field is already an {@link Optional}, you get Optional<Optional<T>>. To avo
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalMapping.java:61
↓ 1 callersMethodprintEmailUsingAccountConsumer
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacesExamples.java:29
↓ 1 callersMethodprintExistingCreditBalancesJava8
(List<CreditAccount> creditAccounts)
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalStream.java:17
↓ 1 callersMethodprintExistingCreditBalancesJava9
(List<CreditAccount> creditAccounts)
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalStream.java:25
↓ 1 callersMethodprintFirstNamesAndCollectEmails
Since forEach() is a terminal operation, you can not continue working with stream when it's performed. That's why Stream API provides another method,
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamAdditionalFeatures.java:59
↓ 1 callersMethodprintFirstNamesSeparatingGmailAccountsAndOthers
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:58
↓ 1 callersMethodprintLongSumUsingBinaryOperation
(long a, long b)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacePrimitives.java:24
↓ 1 callersMethodprintLongValues
{@link LongStream} is a stream of primitive long values. It can also be boxed into a {@link Stream} of {@link Long} values. PLEASE NOTE, that you shou
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamPrimitives.java:24
↓ 1 callersMethodprintMaxBalance
Please note that reduce() was use just an example. The better way to find max balance is to use accounts.stream().max(comparing(Account::getBalance))
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamReducing.java:34
↓ 1 callersMethodprintMaxBalance
This method creates a {@link Stream} of {@link Account} and then maps it to stream of doubles. To transform stream of objects like an {@link Account}
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamPrimitives.java:35
↓ 1 callersMethodprintNamesSeparatedGmailAccountAndOthersAndGroupedByBirthdayMonth
Use streams carefully. Always keep the logic simple and clear. In case it becomes too complex, think how to simplify it use imperative style
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamCollecting.java:82
↓ 1 callersMethodprintOptionalAccount
This is an example of declarative check. You don't write an if statement yourself, it is performed inside the method ifPresentOrElse()
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalImperativeVsDeclarativeCheck.java:32
↓ 1 callersMethodprintPrimeNumbersUsingIntegerPredicate
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacesExamples.java:58
↓ 1 callersMethodprintRandomDoubleUsingSupplier
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacePrimitives.java:18
↓ 1 callersMethodprintResult
Instead of using imperative if-else statement, use ifPresentOrElse() method
5-0-functional-programming/src/main/java/com/bobocode/optionals/tutorial/OptionalReturningMethod.java:35
↓ 1 callersMethodprintSortedFirstNames
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamAdditionalFeatures.java:26
↓ 1 callersMethodprintSqrtUsingFunction
(int a)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacePrimitives.java:30
↓ 1 callersMethodprintSquareOfDoubleUsingFunctionComposition
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/FunctionComposition.java:22
↓ 1 callersMethodprintStringIsBlankUsingPredicateComposition
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/FunctionComposition.java:31
↓ 1 callersMethodprintSumUsingMethodReference
(int a, int b)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodReferenceExamples.java:24
↓ 1 callersMethodprintThirdAndFourthFirstNames
Stream API allow you to skip some elements, and limit the number of elements in the stream
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamAdditionalFeatures.java:37
↓ 1 callersMethodprintTotalBalance
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/streams/tutorial/StreamReducing.java:22
↓ 1 callersMethodprintUpperStringUsingFunction
This is the unbound method reference example. Since we used unbound method reference, the {@link Function} can receive a string as an input parameter.
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodRefToUpperCaseExample.java:23
↓ 1 callersMethodprintUpperStringUsingMethodReference
(String s)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodReferenceExamples.java:31
↓ 1 callersMethodprintUpperStringUsingStringSupplier
This is the bound method reference example. We actually reference a method that is bound to concrete string instance. Since we reference a concrete st
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodRefToUpperCaseExample.java:44
↓ 1 callersMethodprintUpperStringUsingUnaryOperation
This is the unbound method reference example. Since toUpperCase() receives and returns the same type {@link String}, we can easily replace {@link Func
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/MethodRefToUpperCaseExample.java:33
↓ 1 callersMethodprocessAccountWithMaxBalance
Finds an {@link Account} with max balance and processes it using {@link AccountService#processAccount(Account)} @param accounts @param accountService
5-0-functional-programming/5-3-1-crazy-optionals/src/main/java/com/bobocode/fp/CrazyOptionals.java:180
↓ 1 callersMethodprocessByIndex
Find a prime number by index and then applies a provided consumer passing found prime number @param idx the position of a prime number (index),
5-0-functional-programming/5-4-1-fun-prime-numbers/src/main/java/com/bobocode/fp/PrimeNumbers.java:73
↓ 1 callersMethodprocessWithNoAccount
()
5-0-functional-programming/5-3-1-crazy-optionals/src/main/java/com/bobocode/fp/function/AccountService.java:9
↓ 1 callersMethodrandomIntSupplier
Returns a {@link Supplier} of random integers @return int supplier
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:79
↓ 1 callersMethodrun
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaRunnableExample.java:12
↓ 1 callersMethodrunnableToThreadSupplierFunction
Returns a {@link Function} that accepts an instance of {@link Runnable} and returns a {@link Supplier} of a started {@link Thread} that is created fro
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:166
↓ 1 callersMethodrunningThreadSupplier
Receives a {@link Runnable} parameter, and returns a {@link Supplier<Thread>}. The thread will be started only when you call supplier method {@link Su
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:147
↓ 1 callersMethodsayHelloFromNewThread
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaRunnableExample.java:10
↓ 1 callersMethodsayHelloFromNewThreadUsingLambda
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaRunnableExample.java:21
↓ 1 callersMethodsetInnerSize
(int size)
2-0-data-structures-and-algorithms/2-2-2-stack/src/test/java/com/bobocode/cs/LinkedStackTest.java:405
↓ 1 callersMethodsetNext
(Object newNode)
2-0-data-structures-and-algorithms/2-2-9-hash-table/src/test/java/com/bobocode/cs/HashTableTest.java:672
↓ 1 callersMethodsetNextNode
(Object current, Object next)
2-0-data-structures-and-algorithms/2-2-3-linked-queue/src/test/java/com/bobocode/cs/LinkedQueueTest.java:355
↓ 1 callersMethodsetNodeElement
(Node<T> node, T element)
2-0-data-structures-and-algorithms/2-2-1-node/src/test/java/com/bobocode/cs/NodesTest.java:137
↓ 1 callersMethodsetNodeNext
(Node<T> node, Node<T> next)
2-0-data-structures-and-algorithms/2-2-1-node/src/test/java/com/bobocode/cs/NodesTest.java:150
↓ 1 callersMethodsetValue
(Object value)
2-0-data-structures-and-algorithms/2-2-9-hash-table/src/test/java/com/bobocode/cs/HashTableTest.java:667
↓ 1 callersMethodsize
Returns the number of entries (key-value mappings). @return the number of entries
2-0-data-structures-and-algorithms/2-2-9-hash-table/src/main/java/com/bobocode/cs/Map.java:53
↓ 1 callersMethodsortUsingAnonymousClass
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaComparatorExample.java:20
↓ 1 callersMethodsortUsingLambda
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaComparatorExample.java:29
↓ 1 callersMethodsortUsingMethodReference
(List<Account> accounts)
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/LambdaComparatorExample.java:33
↓ 1 callersMethodstringMultiplier
Return a {@link Function} that accepts {@link String} and returns that string repeated n time, where n is passed as function argument @return functio
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:48
↓ 1 callersMethodstringToIntConverter
Returns a {@link ToIntFunction<String>} that converts string to integer. @return string to int converter
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:116
↓ 1 callersMethodtableToString
(Object[] table)
2-0-data-structures-and-algorithms/2-2-9-hash-table/src/test/java/com/bobocode/cs/HashTableTest.java:604
↓ 1 callersMethodthenComparing
Returns a comparator of type T that uses a provided comparator to compare objects, and only if they are equal it's comparing values extracted using th
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:227
↓ 1 callersMethodtoDollarStringFunction
Returns a {@link Function} that converts a {@link BigDecimal} number into a {@link String} that start with a dollar sign and then gets a value @retur
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:58
↓ 1 callersMethodtrickyWellDoneSupplier
Returns {@link Supplier} of {@link Supplier} of {@link Supplier} of {@link String} "WELL DONE!". @return a supplier instance
5-0-functional-programming/5-1-1-crazy-lambdas/src/main/java/com/bobocode/fp/CrazyLambdas.java:237
↓ 1 callersMethodverifyGoogleEmailUsingAccountPredicate
()
5-0-functional-programming/src/main/java/com/bobocode/lambdas/tutorial/PredefinedInterfacesExamples.java:50
MethodAccountNotFoundException
(String message)
5-0-functional-programming/5-3-1-crazy-optionals/src/main/java/com/bobocode/fp/exception/AccountNotFoundException.java:4
MethodArrayList
This constructor creates an instance of {@link ArrayList} with a specific capacity of an array inside. @param initCapacity - the initial capacity of
2-0-data-structures-and-algorithms/2-2-5-array-list/src/main/java/com/bobocode/cs/ArrayList.java:22
MethodBaseEntity
(UUID uuid)
1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/util/BaseEntity.java:17
MethodBox
(Object value)
1-0-java-basics/1-3-0-hello-generics/src/main/java/com/bobocode/basics/Box.java:13
MethodCrazyRegexTest
()
3-0-java-core/3-6-3-crazy-regex/src/test/java/com/bobocode/se/CrazyRegexTest.java:32
MethodEntityNotFoundException
(String message)
5-0-functional-programming/5-2-1-crazy-streams/src/main/java/com/bobocode/fp/exception/EntityNotFoundException.java:4
MethodExerciseNotCompletedException
()
java-fundamentals-util/src/main/java/com/bobocode/util/ExerciseNotCompletedException.java:8
MethodFileStatsException
(String message)
3-0-java-core/3-6-2-file-stats/src/main/java/com/bobocode/se/FileStatsException.java:4
MethodFunctionMap
()
5-0-functional-programming/5-0-1-lambda-functions-map/src/main/java/com/bobocode/fp/FunctionMap.java:18
MethodFunctions
()
5-0-functional-programming/5-0-1-lambda-functions-map/src/main/java/com/bobocode/fp/Functions.java:15
MethodInvalidFunctionNameException
(String functionName)
5-0-functional-programming/5-0-1-lambda-functions-map/src/main/java/com/bobocode/fp/exception/InvalidFunctionNameException.java:4
MethodMaxHolder
(Object max)
1-0-java-basics/1-3-1-crazy-generics/src/main/java/com/bobocode/basics/CrazyGenerics.java:76
MethodNodeProxy
(Object target)
2-0-data-structures-and-algorithms/2-2-9-hash-table/src/test/java/com/bobocode/cs/HashTableTest.java:637
MethodNodes
()
2-0-data-structures-and-algorithms/2-2-1-node/src/main/java/com/bobobode/cs/Nodes.java:14
← previousnext →201–300 of 921, ranked by callers