Q:

How to use JSONObject.computeIfAbsent without lambda expression

Hello guys I want to know how can I use JSONObject.computeIfAbsent without the use of lambda expression. 
Actually, this is my code
list.computeIfAbsent(id, k -> {
            try {
                throw new UnknowClientException("Unkown client : Unable to find client with id" + id);
            } catch (UnknowClientException e) {

            }
        });

I want the function to throw my custom exception. I assume that i need to add thows to the signature of the function and I don't know of to do that with lambda expression that's is why I wan to use a "function"

A:

There is no point in converting the lambda expression into an ordinary class as that doesn’t change the set of permitted exceptions. It’s the implemented interface whose declaration determines the allowed exceptions. Implementors of the interface can’t add checked exception to the throws clause which weren’t covered by already declared ones of the interface.
If you’re talking about the computeIfAbsent method inherited from the Map interface, the method to implement is Function.apply, which doesn’t allow any checked exception.
As an alternative, you can use
result = Optional.ofNullable(list.get(id)).orElseThrow(() -> 
    new UnknowClientException("Unkown client : Unable to find client with id" + id));

The generic method Optional.orElseThrow declares to throw what the provided Supplier declares to create, so if UnknowClientException is a checked exception, the caller will have to catch or declare it, which seems to be your original intention.

