List of Java keywords: Difference between revisions

Content deleted Content added
No edit summary
Link suggestions feature: 2 links added.
 
(5 intermediate revisions by 3 users not shown)
Line 16:
:
;<code>[[boolean data type|boolean]]</code>
:Defines a boolean variable for the values "true" or "false" only. By default, the value of boolean primitive type is false. This keyword is also used to declare that a method returns a value of the primitive type <code>[[boolean data type|boolean]]</code>. In most other languages, the Boolean type is usually simply called <code>bool</code>.
 
;<code>[[break statement|break]]</code>
Line 23:
 
;<code>[[byte]]</code>
:The <code>byte</code> keyword is used to declare a field that can hold an 8-bit signed [[two's complement]] integer.<ref name="primitive"/>{{sfn|Flanagan|2005|p=22}} This keyword is also used to declare that a method returns a value of the primitive type <code>byte</code>.<ref name="return"/>{{sfn|Flanagan|2005|pp=66-67}}
 
;<code>[[switch statement|case]]</code>{{Anchor|case}}
Line 32:
 
;<code>[[character (computing)|char]]</code>
:Defines a character variable capable of holding any character of the javaJava source file's character set.
 
;<code>[[class (computer science)#Java|class]]</code>
:A type that defines the implementation of a particular kind of object. A class definition defines [[Object (computer science)|instance]] and class [[field (computer science)|fields]], [[method (computer science)|methods]], and [[inner class]]es as well as specifying the [[interface (computer science)|interfaces]] the class implements and the immediate [[superclass (computer science)|superclass]] of the class. If the superclass is not explicitly specified, the superclass is implicitly {{Javadoc:SE|java/lang|Object}}. The class keyword can also be used in the form <code>Class'''.class'''</code> to get a <code>Class</code> object without needing an instance of that class. For example, '''<syntaxhighlight lang="Java" inline>String.class'''</syntaxhighlight> can be used instead of doing '''<syntaxhighlight lang="Java" inline>new String().getClass()'''</syntaxhighlight>.
 
;<code>[[continue (Java)|continue]]</code>
Line 80:
 
;<code>import</code>{{Anchor|import}}
:Used at the beginning of a [[source file]] to specify classes or entire [[Java package]]s to be referred to later without including their package names in the reference. Since J2SE 5.0, <code>import</code> statements can import <code>static</code> members of a class. A [[Java Platform Module System|Java module]] may itself be imported (by writing <code>import module</code>), automatically importing all exported packages.<ref>{{Cite web|url=https://openjdk.org/jeps/494|title=JEP 494: Module Import Declarations (Second Preview)|website=openjdk.org}}</ref>
 
;<code>instanceof</code>
Line 122:
 
;<code>[[inheritance (object-oriented programming)|super]]</code>
:Inheritance basically used to achieve dynamic binding or run-time polymorphism in javaJava. Used to access members of a class inherited by the class in which it appears. Allows a subclass to access [[method overriding (programming)|overridden]] methods and hidden members of its superclass. The <code>super</code> keyword is also used to forward a call from a constructor to a constructor in the superclass.
:Also used to specify a lower bound on a type parameter in Generics.
 
Line 152:
 
;<code>[[volatile variable|volatile]]</code>
:Used in field declarations to guarantee visibility of changes to variables across threads. Every read of a volatile variable will be read from main memory, and not from the [[CPU cache]], and that every write to a volatile variable will be written to main memory, and not just to the CPU cache.<ref name="Java Volatile Keyword">{{cite web | title=Java Volatile Keyword | url=http://tutorials.jenkov.com/java-concurrency/volatile.html}}</ref> Methods, classes and interfaces thus cannot be declared ''volatile'', nor can local variables or parameters.
 
;<code>[[do while loop|while]]</code>{{Anchor|while}}