bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/Java/Java Reference
Java•Java Reference

Java Keywords

Java Reserved Keywords

Java has a set of keywords that are reserved words that cannot be used as variables, methods, classes, or any other identifiers:

KeywordDescription
abstractA non-access modifier. Used for classes and methods: An abstract class cannot be used to create objects (to access it, it must be inherited from another class). An abstract method can only be used in an abstract class, and it does not have a body. The body is provided by the subclass (inherited from)
assertFor debugging
booleanA data type that can only store true or false values
breakBreaks out of a loop or a switch block
byteA data type that can store whole numbers from -128 and 127
caseMarks a block of code in switch statements
catchCatches exceptions generated by try statements
charA data type that is used to store a single character
classDefines a class
continueContinues to the next iteration of a loop
constDefines a constant. Not in use - use final instead
defaultSpecifies the default block of code in a switch statement
doUsed together with while to create a do-while loop
doubleA data type that can store fractional numbers from 1.7e−308 to 1.7e+308
elseUsed in conditional statements
enumDeclares an enumerated (unchangeable) type
exportsExports a package with a module. New in Java 9
extendsExtends a class (indicates that a class is inherited from another class)
finalA non-access modifier used for classes, attributes and methods, which makes them non-changeable (impossible to inherit or override)
finallyUsed with exceptions, a block of code that will be executed no matter if there is an exception or not
floatA data type that can store fractional numbers from 3.4e−038 to 3.4e+038
forCreate a for loop
gotoNot in use, and has no function
ifMakes a conditional statement
implementsImplements an interface
importUsed to import a package, class or interface
instanceofChecks whether an object is an instance of a specific class or an interface
intA data type that can store whole numbers from -2147483648 to 2147483647
interfaceUsed to declare a special type of class that only contains abstract methods
longA data type that can store whole numbers from -9223372036854775808 to 9223372036854775808
moduleDeclares a module. New in Java 9
nativeSpecifies that a method is not implemented in the same Java source file (but in another language)
newCreates new objects
packageDeclares a package
privateAn access modifier used for attributes, methods and constructors, making them only accessible within the declared class
protectedAn access modifier used for attributes, methods and constructors, making them accessible in the same package and subclasses
publicAn access modifier used for classes, attributes, methods and constructors, making them accessible by any other class
requiresSpecifies required libraries inside a module. New in Java 9
returnFinished the execution of a method, and can be used to return a value from a method
shortA data type that can store whole numbers from -32768 to 32767
staticA non-access modifier used for methods and attributes. Static methods/attributes can be accessed without creating an object of a class
strictfpObsolete . Restrict the precision and rounding of floating point calculations
superRefers to superclass (parent) objects
switchSelects one of many code blocks to be executed
synchronizedA non-access modifier, which specifies that methods can only be accessed by one thread at a time
thisRefers to the current object in a method or constructor
throwCreates a custom error
throwsIndicates what exceptions may be thrown by a method
transientUsed to ignore an attribute when serializing an object
tryCreates a try...catch statement
varDeclares a variable. New in Java 10
voidSpecifies that a method should not have a return value
volatileIndicates that an attribute is not cached thread-locally, and is always read from the "main memory"
whileCreates a while loop

Note

true , false , and null are not keywords, but they are literals and reserved words that cannot be used as identifiers.

Chapter

Back to Java Reference

Next

Java assert Keyword

This chapter

Overview
264

Lessons

546m

Read time

1. Java Keywords2. Java assert Keyword3. Java abstract Keyword4. Java boolean Keyword5. Java break Keyword6. Java byte Keyword7. Java case Keyword8. Java catch Keyword9. Java char Keyword10. Java class Keyword11. Java continue Keyword12. Java default Keyword13. Java do Keyword14. Java double Keyword15. Java else Keyword16. Java enum Keyword17. Java exports Keyword18. Java extends Keyword19. Java final Keyword20. Java finally Keyword21. Java float Keyword22. Java for Keyword23. Java if Keyword24. Java implements Keyword25. Java import Keyword26. Java instanceof Keyword27. Java int Keyword28. Java interface Keyword29. Java long Keyword30. Java module Keyword31. Java native Keyword32. Java new Keyword33. Java package Keyword34. Java private Keyword35. Java protected Keyword36. Java public Keyword37. Java return Keyword38. Java requires Keyword39. Java short Keyword40. Java static Keyword41. Java super Keyword42. Java switch Keyword43. Java synchronized Keyword44. Java this Keyword45. Java throw Keyword46. Java throws Keyword47. Java transient Keyword48. Java try Keyword49. Java var Keyword50. Java void Keyword51. Java volatile Keyword52. Java while Keyword53. Java String Methods54. Java String charAt() Method55. Java String codePointAt() Method56. Java String codePointBefore() Method57. Java String codePointCount() Method58. Java String compareTo() Method59. Java String compareToIgnoreCase() Method60. Java String concat() Method61. Java String contains() Method62. Java String contentEquals() Method63. Java String copyValueOf() Method64. Java String endsWith() Method65. Java String equals() Method66. Java String equalsIgnoreCase() Method67. Java String format() Method68. Java String getBytes() Method69. Java String getChars() Method70. Java String hashCode() Method71. Java String indexOf() Method72. Java String isEmpty() Method73. Java String join() Method74. Java String lastIndexOf() Method75. Java String length() Method76. Java String matches() Method77. Java String offsetByCodePoints() Method78. Java String regionMatches() Method79. Java String replace() Method80. Java String replaceAll() Method81. Java String replaceFirst() Method82. Java String split() Method83. Java String startsWith() Method84. Java String subSequence() Method85. Java String substring() Method86. Java String toCharArray() Method87. Java String toLowerCase() Method88. Java String toString() Method89. Java String toUpperCase() Method90. Java String trim() Method91. Java String valueOf() Method92. Java Math Methods93. Java Math abs() Method94. Java Math acos() Method95. Java Math addExact() Method96. Java Math asin() Method97. Java Math atan() Method98. Java Math atan2() Method99. Java Math cbrt() Method100. Java Math ceil() Method101. Java Math copySign() Method102. Java Math cos() Method103. Java Math cosh() Method104. Java Math decrementExact() Method105. Java Math exp() Method106. Java Math expm1() Method107. Java Math floor() Method108. Java Math floorDiv() Method109. Java Math floorMod() Method110. Java Math getExponent() Method111. Java Math hypot() Method112. Java Math IEEEremainder() Method113. Java Math incrementExact() Method114. Java Math log() Method115. Java Math log10() Method116. Java Math log1p() Method117. Java Math max() Method118. Java Math min() Method119. Java Math multiplyExact() Method120. Java Math negateExact() Method121. Java Math nextAfter() Method122. Java Math nextDown() Method123. Java Math nextUp() Method124. Java Math pow() Method125. Java Math random() Method126. Java Math rint() Method127. Java Math round() Method128. Java Math scalb() Method129. Java Math signum() Method130. Java Math sin() Method131. Java Math sinh() Method132. Java Math sqrt() Method133. Java Math subtractExact() Method134. Java Math tan() Method135. Java Math tanh() Method136. Java Math toDegrees() Method137. Java Math toIntExact() Method138. Java Math toRadians() Method139. Java Math ulp() Method140. Java Output Methods141. Java Output print() Method142. Java Output printf() Method143. Java Output println() Method144. Java Arrays Class145. Java Arrays. compare() Method146. Java Arrays. equals() Method147. Java Arrays. sort() Method148. Java Arrays. fill() Method149. Java Array length Property150. Java ArrayList Methods151. Java ArrayList add() Method152. Java ArrayList add() Method153. Java ArrayList clear() Method154. Java ArrayList clone() Method155. Java ArrayList contains() Method156. Java ArrayList ensureCapacity() Method157. Java ArrayList forEach() Method158. Java ArrayList get() Method159. Java ArrayList indexOf() Method160. Java ArrayList isEmpty() Method161. Java ArrayList iterator() Method162. Java ArrayList lastIndexOf() Method163. Java ArrayList listIterator() Method164. Java ArrayList remove() Method165. Java ArrayList removeAll() Method166. Java ArrayList removeIf() Method167. Java ArrayList replaceAll() Method168. Java ArrayList retainAll() Method169. Java ArrayList set() Method170. Java ArrayList size() Method171. Java ArrayList sort() Method172. Java ArrayList spliterator() Method173. Java ArrayList subList() Method174. Java ArrayList toArray() Method175. Java ArrayList trimToSize() Method176. Java LinkedList Methods177. Java LinkedList add() Method178. Java LinkedList add() Method179. Java LinkedList clear() Method180. Java LinkedList clone() Method181. Java LinkedList contains() Method182. Java LinkedList forEach() Method183. Java LinkedList get() Method184. Java LinkedList getFirst() Method185. Java LinkedList getLast() Method186. Java LinkedList indexOf() Method187. Java LinkedList isEmpty() Method188. Java LinkedList iterator() Method189. Java LinkedList lastIndexOf() Method190. Java LinkedList listIterator() Method191. Java LinkedList remove() Method192. Java LinkedList removeAll() Method193. Java LinkedList removeFirst() Method194. Java LinkedList removeIf() Method195. Java LinkedList removeLast() Method196. Java LinkedList replaceAll() Method197. Java LinkedList retainAll() Method198. Java LinkedList set() Method199. Java LinkedList size() Method200. Java LinkedList sort() Method201. Java LinkedList spliterator() Method202. Java LinkedList subList() Method203. Java LinkedList toArray() Method204. Java HashMap Methods205. Java HashMap clear() Method206. Java HashMap clone() Method207. Java HashMap compute() Method208. Java HashMap computeIfAbsent() Method209. Java HashMap computeIfPresent() Method210. Java HashMap containsKey() Method211. Java HashMap containsValue() Method212. Java HashMap entrySet() Method213. Java HashMap forEach() Method214. Java HashMap get() Method215. Java HashMap getOrDefault() Method216. Java HashMap isEmpty() Method217. Java HashMap keySet() Method218. Java HashMap merge() Method219. Java HashMap put() Method220. Java HashMap putAll() Method221. Java HashMap putIfAbsent() Method222. Java HashMap remove() Method223. Java HashMap replace() Method224. Java HashMap replaceAll() Method225. Java HashMap size() Method226. Java HashMap values() Method227. Java Scanner Methods228. Java Scanner close() Method229. Java Scanner delimiter() Method230. Java Scanner findInLine() Method231. Java Scanner findWithinHorizon() Method232. Java Scanner hasNext() Method233. Java Scanner hasNextBoolean() Method234. Java Scanner hasNextByte() Method235. Java Scanner hasNextDouble() Method236. Java Scanner hasNextFloat() Method237. Java Scanner hasNextInt() Method238. Java Scanner hasNextLine() Method239. Java Scanner hasNextLong() Method240. Java Scanner hasNextShort() Method241. Java Scanner locale() Method242. Java Scanner next() Method243. Java Scanner nextBoolean() Method244. Java Scanner nextByte() Method245. Java Scanner nextDouble() Method246. Java Scanner nextFloat() Method247. Java Scanner nextInt() Method248. Java Scanner nextLine() Method249. Java Scanner nextLong() Method250. Java Scanner nextShort() Method251. Java Scanner radix() Method252. Java Scanner reset() Method253. Java Scanner useDelimiter() Method254. Java Scanner useLocale() Method255. Java Scanner useRadix() Method256. Java File Class Methods257. Java FileInputStream Methods258. Java FileOutputStream Methods259. Java BufferedReader Methods260. Java BufferedWriter Methods261. Java Iterator Interface262. Java Collections Class Methods263. Java System Methods264. Java Errors and Exception Types