# Java Keywords - Các từ khóa trong Java Keywords (Từ khóa) là những từ đã được định nghĩa cho trình biên dịch Java. Chúng có ý nghĩa đặc biệt cho trình biên dịch. Từ khóa Java phải có trong thông tin của bạn vì bạn không thể sử dụng chúng làm biến, lớp hoặc tên phương thức. Bạn không thể sử dụng từ khóa làm định danh trong các chương trình Java của mình, các từ dành riêng trong thư viện Java và được sử dụng để thực hiện thao tác nội bộ.
abstractassertbooleanbreak
bytecasecatchchar
classconstcontinuedefault
dodoubleelseenum
extendsfinalfinallyfloat
forgotoifimplements
importinstanceofintinterface
longnativenewpackage
privateprotectedpublicreturn
shortstaticstrictfpsuper
switchsynchronizedthisthrow
throwstransienttryvoid
volatilewhile true false
null
1. **abstract** - Chỉ ra rằng class hoặc phương thức sẽ phải thực thi sau đó trong một subclass. 2. **assert** - Là keyword có từ Java 1.4 sử dụng để kiểm tra một biểu thức có đúng hay không, thường sử dụng cho việc viết code unit test. Trong Java sử dụng assert có 2 cách viết. 3. **boolean** - Kiểu dữ liệu chỉ có giá trị True và False 4. **break** – A control statement for breaking out of loops 5. **byte** – A data type that can hold 8-bit data values 6. **case** – Used in switch statements to mark blocks of text 7. **catch** – Catches exceptions generated by try statements 8. **char** – A data type that can hold unsigned 16-bit Unicode characters 9. **class** -Declares a new class 10. **continue** -Sends control back outside a loop 11. **default** -Specifies the default block of code in a switch statement 12. **do** -Starts a do-while loop 13. **double** – A data type that can hold 64-bit floating-point numbers 14. **else** – Indicates alternative branches in an if statement 15. **enum** – A Java keyword used to declare an enumerated type. Enumerations extend the base class. 16. **extends** -Indicates that a class is derived from another class or interface 17. **final** -Indicates that a variable holds a constant value or that a method will not be overridden 18. **finally** -Indicates a block of code in a try-catch structure that will always be executed 19. **float** -A data type that holds a 32-bit floating-point number 20. **for** -Used to start a for loop 21. **if** -Tests a true/false expression and branches accordingly 22. **implements** -Specifies that a class implements an interface 23. **import** -References other classes 24. **instanceof** -Indicates whether an object is an instance of a specific class or implements an interface 25. **int** – A data type that can hold a 32-bit signed integer 26. **interface** – Declares an interface 27. **long** – A data type that holds a 64-bit integer 28. **native** -Specifies that a method is implemented with native (platform-specific) code 29. **new** – Creates new objects 30. **null** -Indicates that a reference does not refer to anything 31. **package** – Declares a Java package 32. **private** -An access specifier indicating that a method or variable may be accessed only in the class it’s declared in 33. **protected** – An access specifier indicating that a method or variable may only be accessed in the class it’s declared in (or a subclass of the class it’s declared in or other classes in the same package) 34. **public** – An access specifier used for classes, interfaces, methods, and variables indicating that an item is accessible throughout the application (or where the class that defines it is accessible) 35. **return** -Sends control and possibly a return value back from a called method 36. **short** – A data type that can hold a 16-bit integer 37. **static** -Indicates that a variable or method is a class method (rather than being limited to one particular object) 38. **strictfp** - Là keyword đảm bảo cho bạn sẽ nhận một kết quả như nhau khi thực hiện các toán tử với số thập phân trên các platform’s hardware khác nhau. Keyword này có thể được sử dụng cho classes, interfaces and methods. 39. **super** – Refers to a class’s base class (used in a method or class constructor) 40. **switch** -A statement that executes code based on a test value 41. **synchronized** -Specifies critical sections or methods in multithreaded code 42. **this** -Refers to the current object in a method or constructor 43. **throw** – Creates an exception 44. **throws** -Indicates what exceptions may be thrown by a method 45. **transient** - Là keyword sẽ thông báo cho JVM biết đối tượng được transient sẽ không được serialization khi truyền qua IO (cũng có nghĩa là đối tượng đó sẽ không được chuyển qua mạng) 46. **try** -Starts a block of code that will be tested for exceptions 47. **void** -Specifies that a method does not have a return value 48. **volatile** -Indicates that a variable may change asynchronously 49. **while** -Starts a while loop **\*\*** The keywords **const** and **goto** are reserved, even they are not currently in use. - **const** -Reserved for future use - **goto** – Reserved for future use **\*\* true, false** and **null** không phải là các từ dành riêng nhưng không thể được sử dụng làm định danh, bởi vì nó là giá trị của các kiểu dữ liệu.