Java 8 method references, double colon (::) operator

In Java 8, the double colon (::) operator is called method references. Refer to the following examples: Anonymous class to print a list. List<String> list = Arrays.asList("node", "java", "python", "ruby"); list.forEach(new Consumer<String>() { // anonymous class @Override public void accept(String str) { System.out.println(str); } }); Anonymous class -> Lambda expressions. List<String> list = Arrays.asList("node", "java", …

Read more

Java 8 UnaryOperator Examples

In Java 8, UnaryOperator is a functional interface and it extends Function. The UnaryOperator takes one argument, and returns a result of the same type of its arguments. UnaryOperator.java @FunctionalInterface public interface UnaryOperator<T> extends Function<T, T> { } The Function takes one argument of any type and returns a result of any type. Function.java @FunctionalInterface …

Read more

Oracle PL/SQL – ALTER function example

The ALTER FUNCTION statement explicitly recompile a standalone function. Sometimes, ALTER TABLE on the table being used in function will cause the function becomes INVALID, we need to recompile (alter function) it to make it VALID again. 1. ALTER function example First, we will create table test_alter, function get_max_amount. In this function, we are using …

Read more

Oracle PL/SQL – DROP function example

This article shows you how to use DROP FUNCTION to delete a function from Oracle database. 1. DROP function example 1.1 Create a function get_current_month. Then we will delete the function using DROP FUNCTION statement. –Creating function CREATE OR REPLACE FUNCTION get_current_month RETURN VARCHAR2 IS curr_month VARCHAR2(10); BEGIN SELECT to_char(sysdate, ‘MONTH’) INTO curr_month FROM dual; …

Read more