Jul 8, 2024
try
, catch
, and finally
blockspublic static void main
)try
, catch
, and finally
try
/catch
: Even if a return
statement is executed, the finally
block still runs.try
with finally
without catch
: It's possible to handle cleanup without a catch
block to propagate exceptions.try
, catch
, and finally
can slightly impact performance due to exception handling overhead but is generally minimal.finally
block won’t execute if JVM exits via System.exit()
during try
or catch
execution.finally
blocks are not allowed within a single try
-catch
-finally
structure.catch
block separated by a pipe |
symbol to handle multiple exceptions with the same logic.Mark-Sweep
, Mark-Compact
, Generational Copying
are used depending on the collector chosen.int
, char
which are not objects.int
) help Java run faster and use less memory.public static void main(String[] args)
is the entry point of Java applications.
public
: Accessible from anywhere.static
: Doesn’t need an object instance to be called.void
: Doesn’t return any value.main
: Method name.null
. Default values are provided (e.g., 0
for int
, false
for boolean
).static
and default
methods but no state.static
and default
methods.dual-pivot quicksort
for primitives, timsort
for objects).
ServerSocket
for TCP, HttpServer
for HTTP).