In java code, when to expect to throw an exception with a throw statement and when to catch an exception with a try/catch block?
Moreover, how to distinguish between a situation in which an exception should be caught by a method or throw to its caller.

If the method in which the exception may occur is capable of handling that exception, then you catch it, otherwise you throw it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.