Complete list of Java keywords: abstract, assert, boolean, break, byte, case, catch, char, class, const, continue, default, do, double, else, enum, extends, final, finally, float, for, goto, if, implements, import, instanceof, int, interface, long, native, new, package, private, protected, public, return, short, static, strictfp, super, switch, synchronized, this, throw, transient, try, void, volatile, while.
Reserved words for literal use: true, null, false.
None of these are Java keywords.
Final, finally, finalize in Java?*Final is a modifier that can be applied to classes, methods, fields, variables and parameters. Classes cannot be extended, methods cannot be overridden, fields cannot be assigned multiple times and must be instantiated in the constructors, variables can only be assigned once and parameters cannot be assigned. Finalize is the method called just before the object is garbage collected. Finally indicated the code block to be executed in connection with a try/catch block. The
finallycode is executed even if the function returns a value in try/catch and can change the return value.
What are the final fields and final methods?
The static keyword is used to declare fields, methods or inner classes. Objects hold a single copy of the fields no matter how many instance are there. Static member classes are actually top-level classes and not inner classes.
What if I write
static public voidinstead of
public static void?Program compiles, no error, the same thing.
How is the
Transient modifier applies to members that are not stored during serialization.
Volatile fields can be modified asynchronously by multiple threads.
constkeywords used in Java?
Although these are actually keywords, they are not used and don’t serve any purpose.