text:
Java syntax

The syntax of Java is the set of rules defining how a Java program is written and interpreted.

The syntax is mostly derived from C and C++. Unlike in C++, in Java there are no global functions or variables, but there are data members which are also regarded as global variables. All code belongs to classes and all values are objects. The only exception is the primitive types, which are not considered to be objects for performance reasons (though can be automatically converted to objects and vice versa via autoboxing). Some features like operator overloading or unsigned integer types are omitted to simplify the language and to avoid possible programming mistakes.

The Java syntax has been gradually extended in the course of numerous major JDK releases, and now supports capabilities such as generic programming and function literals (called lambda expressions in Java). Since 2017, a new JDK version is released twice a year, with each release bringing incremental improvements to the language.

Identifier
An identifier is the name of an element in the code. There are certain standard naming conventions to follow when selecting names for elements. Identifiers in Java are case-sensitive.

An identifier can contain:
 * Any Unicode character that is a letter (including numeric letters like Roman numerals) or digit.
 * Currency sign (such as ¥).
 * Connecting punctuation character (such as _).

An identifier cannot:
 * Start with a digit.
 * Be equal to a reserved keyword, null literal or boolean literal.

Literals
Integer literals are of  type by default unless   type is specified by appending   or   suffix to the literal, e.g.  . Since Java SE 7, it is possible to include underscores between the digits of a number to increase readability; for example, a number 145608987 can be written as 145_608_987.

Variables
Variables are identifiers associated with values. They are declared by writing the variable's type and name, and are optionally initialized in the same statement by assigning a value.

Multiple variables of the same type can be declared and initialized in one statement using comma as a delimiter.

Type inference
Since Java 10, it has become possible to infer types for the variables automatically by using.

Code blocks
The separators $($ and $)$ signify a code block and a new scope. Class members and the body of a method are examples of what can live inside these braces in various contexts.

Inside of method bodies, braces may be used to create new scopes, as follows:

Comments
Java has three kinds of comments: traditional comments, end-of-line comments and documentation comments.

Traditional comments, also known as block comments, start with  and end with , they may span across multiple lines. This type of comment was derived from C and C++.

End-of-line comments start with  and extend to the end of the current line. This comment type is also present in C++ and in modern C.

Documentation comments in the source files are processed by the Javadoc tool to generate documentation. This type of comment is identical to traditional comments, except it starts with  and follows conventions defined by the Javadoc tool. Technically, these comments are a special kind of traditional comment and they are not specifically defined in the language specification.

Universal types
Classes in the package java.lang are implicitly imported into every program, as long as no explicitly-imported types have the same names. Important ones include:

java.lang.Object
java.lang.Object is Java's top type. Superclass of all classes that do not declare a parent class. All values can be converted to this type, although for primitive values this involves autoboxing.

java.lang.String
java.lang.String is Java's basic string type. Immutable. Some methods treat each UTF-16 code unit as a "character", but methods to convert to an  that is effectively UTF-32 are also available.

java.lang.Throwable
java.lang.Throwable is supertype of everything that can be thrown or caught with Java's  and   statements.

Program structure
Java applications consist of collections of classes. Classes exist in packages but can also be nested inside other classes.

method
Every Java application must have an entry point. This is true of both graphical interface applications and console applications. The entry point is the  method. There can be more than one class with a  method, but the main class is always defined externally (for example, in a manifest file). The  method along with the main class must be declared. The method must be  and is passed command-line arguments as an array of strings. Unlike C++ or C#, it never returns a value and must return.

Packages
Packages are a part of a class name and they are used to group and/or distinguish named entities from other ones. Another purpose of packages is to govern code access together with access modifiers. For example,  is a fully qualified class name for the class   which is located in the package.

A package is declared at the start of the file with the  declaration:

Classes with the  modifier must be placed in the files with the same name and java extension and put into nested folders corresponding to the package name. The above class  will have the following path:.

Type import declaration
A type import declaration allows a named type to be referred to by a simple name rather than the full name that includes the package. Import declarations can be single type import declarations or import-on-demand declarations. Import declarations must be placed at the top of a code file after the package declaration.

Import-on-demand declarations are mentioned in the code. A "type import" imports all the types of the package. A "static import" imports members of the package.

Static import declaration
This type of declaration has been available since J2SE 5.0. Static import declarations allow access to static members defined in another class, interface, annotation, or enum; without specifying the class name:

Import-on-demand declarations allow to import all the fields of the type:

Enum constants may also be used with static import. For example, this enum is in the package called :

It is possible to use static import declarations in another class to retrieve the enum constants:

Operators
Operators in Java are similar to those in C++. However, there is no  operator due to garbage collection mechanisms in Java, and there are no operations on pointers since Java does not support them. Another difference is that Java has an unsigned right shift operator, while C's right shift operator's signedness is type-dependent. Operators in Java cannot be overloaded.

statement
if statements in Java are similar to those in C and use the same syntax:

statement may include optional  block, in which case it becomes an if-then-else statement:

Like C, else-if construction does not involve any special keywords, it is formed as a sequence of separate if-then-else statements:

Also, note that the ?: operator can be used in place of simple if statement, for example

statement
Switch statements in Java can use,  ,  , and   (note: not  ) primitive data types or their corresponding wrapper types. Starting with J2SE 5.0, it is possible to use enum types. Starting with Java SE 7, it is possible to use Strings. Other reference types cannot be used in  statements.

Possible values are listed using  labels. These labels in Java may contain only constants (including enum constants and string constants). Execution will start after the label corresponding to the expression inside the brackets. An optional  label may be present to declare that the code following it will be executed if none of the case labels correspond to the expression.

Code for each label ends with the  keyword. It is possible to omit it causing the execution to proceed to the next label, however, a warning will usually be reported during compilation.

expressions
Since Java 14 it has become possible to use switch expressions, which use the new arrow syntax:

Alternatively, there is a possibility to express the same with the  statement, although it is recommended to prefer the arrow syntax because it avoids the problem of accidental fall throughs.

Iteration statements
Iteration statements are statements that are repeatedly executed when a given condition is evaluated as true. Since J2SE 5.0, Java has four forms of such statements. Note that the condition must have type boolean or Boolean, meaning C's results in a compilation error.

loop
In the  loop, the test is done before each iteration.

loop
In the  loop, the test is done after each iteration. Consequently, the code is always executed at least once.

loop
loops in Java include an initializer, a condition and a counter expression. It is possible to include several expressions of the same kind using comma as delimiter (except in the condition). However, unlike C, the comma is just a delimiter and not an operator.

Like C, all three expressions are optional. The following loop is infinite:

Enhanced loop
Enhanced  loops have been available since J2SE 5.0. This type of loop uses built-in iterators over arrays and collections to return each item in the given collection. Every element is returned and reachable in the context of the code block. When the block is executed, the next item is returned until there are no items remaining. Unlike C#, this kind of loop does not involve a special keyword, but instead uses a different notation style.

Labels
Labels are given points in code used by  and   statements. Note that the Java  keyword cannot be used to jump to specific points in the code.

statement
The  statement breaks out of the closest loop or   statement. Execution continues in the statement after the terminated statement, if any.

It is possible to break out of the outer loop using labels:

statement
The  statement discontinues the current iteration of the current control statement and begins the next iteration. The following  loop in the code below reads characters by calling , skipping the statements in the body of the loop if the characters are spaces:

Labels can be specified in  statements and   statements:

statement
The  statement is used to end method execution and to return a value. A value returned by the method is written after the  keyword. If the method returns anything but, it must use the   statement to return some value.

statement ends execution immediately, except for one case: if the statement is encountered within a  block and it is complemented by a , control is passed to the   block.

statements
Exceptions are managed within  ...   blocks.

The statements within the  block are executed, and if any of them throws an exception, execution of the block is discontinued and the exception is handled by the   block. There may be multiple  blocks, in which case the first block with an exception variable whose type matches the type of the thrown exception is executed.

Java SE 7 also introduced multi-catch clauses besides uni-catch clauses. This type of catch clauses allows Java to handle different types of exceptions in a single block provided they are not subclasses of each other.

If no  block matches the type of the thrown exception, the execution of the outer block (or method) containing the   ...   statement is discontinued, and the exception is passed up and outside the containing block (or method). The exception is propagated upwards through the call stack until a matching  block is found within one of the currently active methods. If the exception propagates all the way up to the top-most  method without a matching   block being found, a textual description of the exception is written to the standard output stream.

The statements within the  block are always executed after the   and   blocks, whether or not an exception was thrown and even if a   statement was reached. Such blocks are useful for providing clean-up code that is guaranteed to always be executed.

The  and   blocks are optional, but at least one or the other must be present following the   block.

-with-resources statements
-with-resources statements are a special type of  statements introduced as an implementation of the dispose pattern in Java SE 7. In a -with-resources statement the   keyword is followed by initialization of one or more resources that are released automatically when the   block execution is finished. Resources must implement. -with-resources statements are not required to have a  or   block unlike normal   statements.

Since Java 9 it is possible to use already declared variables:

statement
The  statement is used to throw an exception and end the execution of the block or method. The thrown exception instance is written after the  statement.

Thread concurrency control
Java has built-in tools for multi-thread programming. For the purposes of thread synchronization the  statement is included in Java language.

To make a code block synchronized, it is preceded by the  keyword followed by the lock object inside the brackets. When the executing thread reaches the synchronized block, it acquires a mutual exclusion lock, executes the block, then releases the lock. No threads may enter this block until the lock is released. Any non-null reference type may be used as the lock.

statement
statements have been available since J2SE 1.4. These types of statements are used to make assertions in the source code, which can be turned on and off during execution for specific classes or packages. To declare an assertion the  keyword is used followed by a conditional expression. If it evaluates to  when the statement is executed, an exception is thrown. This statement can include a colon followed by another expression, which will act as the exception's detail message.

Primitive types
Primitive types in Java include integer types, floating-point numbers, UTF-16 code units and a boolean type. There are no unsigned types in Java except  type, which is used to represent UTF-16 code units. The lack of unsigned types is offset by introducing unsigned right shift operation, which is not present in C++. Nevertheless, criticisms have been leveled about the lack of compatibility with C and C++ this causes.

does not necessarily correspond to a single character. It may represent a part of a surrogate pair, in which case Unicode code point is represented by a sequence of two  values.

Boxing and unboxing
This language feature was introduced in J2SE 5.0. Boxing is the operation of converting a value of a primitive type into a value of a corresponding reference type, which serves as a wrapper for this particular primitive type. Unboxing is the reverse operation of converting a value of a reference type (previously boxed) into a value of a corresponding primitive type. Neither operation requires an explicit conversion.

Example:

Reference types
Reference types include class types, interface types, and array types. When the constructor is called, an object is created on the heap and a reference is assigned to the variable. When a variable of an object gets out of scope, the reference is broken and when there are no references left, the object gets marked as garbage. The garbage collector then collects and destroys it some time afterwards.

A reference variable is  when it does not reference any object.

Arrays
Arrays in Java are created at runtime, just like class instances. Array length is defined at creation and cannot be changed.

Multi-dimensional arrays
In Java, multi-dimensional arrays are represented as arrays of arrays. Technically, they are represented by arrays of references to other arrays.

Due to the nature of the multi-dimensional arrays, sub-arrays can vary in length, so multi-dimensional arrays are not bound to be rectangular unlike C:

Classes
Classes are fundamentals of an object-oriented language such as Java. They contain members that store and manipulate data. Classes are divided into top-level and nested. Nested classes are classes placed inside another class that may access the private members of the enclosing class. Nested classes include member classes (which may be defined with the static modifier for simple nesting or without it for inner classes), local classes and anonymous classes.

Instantiation
Non-static members of a class define the types of the instance variables and methods, which are related to the objects created from that class. To create these objects, the class must be instantiated by using the  operator and calling the class constructor.

Accessing members
Members of both instances and static classes are accessed with the  (dot) operator.

Accessing an instance member Instance members can be accessed through the name of a variable.

Accessing a static class member Static members are accessed by using the name of the class or any other type. This does not require the creation of a class instance. Static members are declared using the  modifier.

Modifiers
Modifiers are keywords used to modify declarations of types and type members. Most notably there is a sub-group containing the access modifiers.

 *   - Specifies that a class only serves as a base class and cannot be instantiated.
 *   - Used only for member classes, specifies that the member class does not belong to a specific instance of the containing class.
 *   - Classes marked as  cannot be extended from and cannot have any subclasses.
 *   - Specifies that all floating-point operations must be carried out conforming to IEEE 754 and forbids using enhanced precision to store intermediate results.

Access modifiers
The access modifiers, or inheritance modifiers, set the accessibility of classes, methods, and other members. Members marked as  can be reached from anywhere. If a class or its member does not have any modifiers, default access is assumed.

The following table shows whether code within a class has access to the class or method depending on the accessing class location and the modifier for the accessed class or class member:

Constructors and initializers
A constructor is a special method called when an object is initialized. Its purpose is to initialize the members of the object. The main differences between constructors and ordinary methods are that constructors are called only when an instance of the class is created and never return anything. Constructors are declared as common methods, but they are named after the class and no return type is specified:

Initializers are blocks of code that are executed when a class or an instance of a class is created. There are two kinds of initializers, static initializers and instance initializers.

Static initializers initialize static fields when the class is created. They are declared using the  keyword:

A class is created only once. Therefore, static initializers are not called more than once. On the contrary, instance initializers are automatically called before the call to a constructor every time an instance of the class is created. Unlike constructors instance initializers cannot take any arguments and generally they cannot throw any checked exceptions (except in several special cases). Instance initializers are declared in a block without any keywords:

Since Java has a garbage collection mechanism, there are no destructors. However, every object has a  method called prior to garbage collection, which can be overridden to implement finalization.

Methods
All the statements in Java must reside within methods. Methods are similar to functions except they belong to classes. A method has a return value, a name and usually some parameters initialized when it is called with some arguments. Similar to C++, methods returning nothing have return type declared as. Unlike in C++, methods in Java are not allowed to have default argument values and methods are usually overloaded instead.

A method is called using  notation on an object, or in the case of a static method, also on the name of a class.

The  keyword indicates that a method throws an exception. All checked exceptions must be listed in a comma-separated list.

Modifiers

 *   - Abstract methods can be present only in abstract classes, such methods have no body and must be overridden in a subclass unless it is abstract itself.
 *   - Makes the method static and accessible without creation of a class instance. However static methods cannot access non-static members in the same class.
 *   - Declares that the method cannot be overridden in a subclass.
 *   - Indicates that this method is implemented through JNI in platform-dependent code. Actual implementation happens outside Java code, and such methods have no body.
 *   - Declares strict conformance to IEEE 754 in carrying out floating-point operations.
 *   - Declares that a thread executing this method must acquire monitor. For  methods the monitor is the class instance or   if the method is static.
 * Access modifiers - Identical to those used with classes.

Varargs
This language feature was introduced in J2SE 5.0. The last argument of the method may be declared as a variable arity parameter, in which case the method becomes a variable arity method (as opposed to fixed arity methods) or simply varargs method. This allows one to pass a variable number of values, of the declared type, to the method as parameters - including no parameters. These values will be available inside the method as an array.

Fields
Fields, or class variables, can be declared inside the class body to store data.

Fields can be initialized directly when declared.

Modifiers

 *   - Makes the field a static member.
 *   - Allows the field to be initialized only once in a constructor or inside initialization block or during its declaration, whichever is earlier.
 *   - Indicates that this field will not be stored during serialization.
 *   - If a field is declared, it is ensured that all threads see a consistent value for the variable.

Inheritance
Classes in Java can only inherit from one class. A class can be derived from any class that is not marked as. Inheritance is declared using the  keyword. A class can reference itself using the  keyword and its direct superclass using the   keyword.

If a class does not specify its superclass, it implicitly inherits from  class. Thus all classes in Java are subclasses of  class.

If the superclass does not have a constructor without parameters the subclass must specify in its constructors what constructor of the superclass to use. For example:

Overriding methods
Unlike C++, all non- methods in Java are virtual and can be overridden by the inheriting classes.

Abstract classes
An Abstract Class is a class that is incomplete, or is to be considered incomplete, so cannot be instantiated.

A class C has abstract methods if any of the following is true:

 * C explicitly contains a declaration of an abstract method.
 * Any of C's superclasses has an abstract method and C neither declares nor inherits a method that implements it.
 * A direct superinterface of C declares or inherits a method (which is therefore necessarily abstract) and C neither declares nor inherits a method that implements it.
 * A subclass of an abstract class that is not itself abstract may be instantiated, resulting in the execution of a constructor for the abstract class and, therefore, the execution of the field initializers for instance variables of that class.

Output:

Enumerations
This language feature was introduced in J2SE 5.0. Technically enumerations are a kind of class containing enum constants in its body. Each enum constant defines an instance of the enum type. Enumeration classes cannot be instantiated anywhere except in the enumeration class itself.

Enum constants are allowed to have constructors, which are called when the class is loaded:

Enumerations can have class bodies, in which case they are treated like anonymous classes extending the enum class:

Interfaces
Interfaces are types which contain no fields and usually define a number of methods without an actual implementation. They are useful to define a contract with any number of different implementations. Every interface is implicitly abstract. Interface methods are allowed to have a subset of access modifiers depending on the language version,, which has the same effect as for classes, and also   since Java SE 8.

Implementing an interface
An interface is implemented by a class using the  keyword. It is allowed to implement more than one interface, in which case they are written after  keyword in a comma-separated list. A class implementing an interface must override all its methods, otherwise it must be declared as abstract.

Functional interfaces and lambda expressions
These features were introduced with the release of Java SE 8. An interface automatically becomes a functional interface if it defines only one method. In this case an implementation can be represented as a lambda expression instead of implementing it in a new class, thus greatly simplifying writing code in the functional style. Functional interfaces can optionally be annotated with the  annotation, which will tell the compiler to check whether the interface actually conforms to a definition of a functional interface.

Lambda's parameters types don't have to be fully specified and can be inferred from the interface it implements. Lambda's body can be written without a body block and a  statement if it is only an expression. Also, for those interfaces which only have a single parameter in the method, round brackets can be omitted.

Method references
It is not necessary to use lambdas when there already is a named method compatible with the interface. This method can be passed instead of a lambda using a method reference. There are several types of method references:

The code above which calls  could be replaced with the following using the method references:

Inheritance
Interfaces can inherit from other interfaces just like classes. Unlike classes it is allowed to inherit from multiple interfaces. However, it is possible that several interfaces have a field with the same name, in which case it becomes a single ambiguous member, which cannot be accessed.

Default methods
Java SE 8 introduced default methods to interfaces which allows developers to add new methods to existing interfaces without breaking compatibility with the classes already implementing the interface. Unlike regular interface methods, default methods have a body which will get called in the case if the implementing class doesn't override it.

Static methods
Static methods is another language feature introduced in Java SE 8. They behave in exactly the same way as in the classes.

Private methods
Private methods were added in the Java 9 release. An interface can have a method with a body marked as private, in which case it will not be visible to inheriting classes. It can be called from default methods for the purposes of code reuse.

Annotations
Annotations in Java are a way to embed metadata into code. This language feature was introduced in J2SE 5.0.

Annotation types
Java has a set of predefined annotation types, but it is allowed to define new ones. An annotation type declaration is a special type of an interface declaration. They are declared in the same way as the interfaces, except the  keyword is preceded by the   sign. All annotations are implicitly extended from  and cannot be extended from anything else.

Annotations may have the same declarations in the body as the common interfaces, in addition they are allowed to include enums and annotations. The main difference is that abstract method declarations must not have any parameters or throw any exceptions. Also they may have a default value, which is declared using the  keyword after the method name:

Usage of annotations
Annotations may be used in any kind of declaration, whether it is package, class (including enums), interface (including annotations), field, method, parameter, constructor, or local variable. Also they can be used with enum constants. Annotations are declared using the  sign preceding annotation type name, after which element-value pairs are written inside brackets. All elements with no default value must be assigned a value.

Besides the generic form, there are two other forms to declare an annotation, which are shorthands. Marker annotation is a short form, it is used when no values are assigned to elements:

The other short form is called single element annotation. It is used with annotations types containing only one element or in the case when multiple elements are present, but only one elements lacks a default value. In single element annotation form the element name is omitted and only value is written instead:

Generics
Generics, or parameterized types, or parametric polymorphism is one of the major features introduced in J2SE 5.0. Before generics were introduced, it was required to declare all the types explicitly. With generics it became possible to work in a similar manner with different types without declaring the exact types. The main purpose of generics is to ensure type safety and to detect runtime errors during compilation. Unlike C#, information on the used parameters is not available at runtime due to type erasure.

Generic classes
Classes can be parameterized by adding a type variable inside angle brackets ( and  ) following the class name. It makes possible the use of this type variable in class members instead of actual types. There can be more than one type variable, in which case they are declared in a comma-separated list.

It is possible to limit a type variable to a subtype of some specific class or declare an interface that must be implemented by the type. In this case the type variable is appended by the  keyword followed by a name of the class or the interface. If the variable is constrained by both class and interface or if there are several interfaces, the class name is written first, followed by interface names with  sign used as the delimiter.

When a variable of a parameterized type is declared or an instance is created, its type is written exactly in the same format as in the class header, except the actual type is written in the place of the type variable declaration.

Since Java SE 7, it is possible to use a diamond in place of type arguments, in which case the latter will be inferred. The following code in Java SE 7 is equivalent to the code in the previous example:

When declaring a variable for a parameterized type, it is possible to use wildcards instead of explicit type names. Wildcards are expressed by writing  sign instead of the actual type. It is possible to limit possible types to the subclasses or superclasses of some specific class by writing the  keyword or the   keyword correspondingly followed by the class name.

Generic methods and constructors
Usage of generics may be limited to some particular methods, this concept applies to constructors as well. To declare a parameterized method, type variables are written before the return type of the method in the same format as for the generic classes. In the case of constructor, type variables are declared before the constructor name.

Generic interfaces
Interfaces can be parameterized in the similar manner as the classes.

title: Java syntax


text:
Talk:Java syntax

From WP:RfD

 * Java syntax → Java programming language -- I just switched it; it had been pointing to what's now Curly bracket programming language. I don't think anyone's likely ever to use this redirect. Quuxplusone 21:06, 21 July 2005 (UTC)
 * "Java syntax" gets about 60K web hits. I'd say "keep", lest someone start a new article. Noel (talk) 03:08, 29 July 2005 (UTC)

Semantics and BNF grammar
Anybody reading this article could be forgiven for thinking that Java did not include any semantic requirements (ie, the article reads like everything is specified in the syntax).

This article could do with a major rewrite that separated out the lexical/syntax/semantic issues. And come on guys, an article on syntax that fails to list at least a few production from the BNF grammar :-O.

Come to think about it, the problem is not the content but the title. The title "A brief introduction to some Java features" is closer to what the text is about. Derek farn 15:41, 24 April 2006 (UTC)

Java 5 features
This article does not cover Java annotations or generic/parameterized types. Mike Dillon 15:56, 9 August 2006 (UTC)

Book References
Herb Schildt is widely regarded as being one of the worst technical authors around. Should we really be referencing one of his books at the bottom of the article - especially since theres no shortage of other books on Java. 82.71.7.193 22:05, 29 August 2006 (UTC)

Operator precedence needed
I don't have time at the moment, but the article should indicate the operator precedence and discuss operator precedence. —Doug Bell talk•contrib 20:33, 3 November 2006 (UTC)

why did somebody delete the chinese java example?
http://en.wikipedia.org/w/index.php?title=Java_syntax&diff=130736395&oldid=123256628 Booksonlysuc 01:19, 1 August 2007 (UTC)
 * My theory is that some overzealous editor saw the Chinese characters and decided to translate for us, without realizing they were intentional. I restored them. --  Max   Talk [ (add)] 01:45, 1 August 2007 (UTC)

things needed

 * Exception
 * Thread object, Runnable interface and their methods
 * synchronized block
 * local variables and their scope
 * Autoboxing

anything else? 220.146.142.210 11:48, 22 August 2007 (UTC)

Wrapper types as "pass-by-reference"?
Aren't wrapper types immutable? If so, they cannot be used to pass by reference as the article says 201.21.71.226 (talk) 01:40, 25 December 2008 (UTC)

Stubbing this pending rewrite
The recent AfD for this article came up as no consensus, but that was mostly due to the potential use of an article on this subject rather than anything which currently exists in it. I've taken the opportunity to remove the useless material pending a full rewrite from scratch, as its existence made that less likely; it was, of course, quickly reverted by anon complaining about it being "destroyed". if there's no better argument for restoring the cruft which has now been transwikied to a WikiBooks manual (where it belongs) then I'll remove it again. Chris Cunningham (not at work) - talk 09:26, 6 February 2009 (UTC)
 * I support the stubbing suggestion based on the history and the result of the AfD. Wikipedia is not and all that. Give it a couple of more days and then redo it. If it is again summarily reverted w/o comment here, at least you'll clearly be in the right. Usrnme h8er (talk) 15:01, 9 February 2009 (UTC)

 * I've now restored the stubbed version, as there has been no response from any party wishing to keep the old version - one which was generally disliked in the AfD. This gives the article room to re-grow as a descriptive rather than prescriptive work. Chris Cunningham (not at work) - talk 20:38, 18 February 2009 (UTC)
 * i'm sorely disappointed. the previous page was useful reference despite whatever your claim is that it's what wikipedia isn't supposed to be. may as well delete half of the mathematics articles that i reference in the same manner as i did this page. way to make wikipedia less useful than it should be. — Preceding unsigned comment added by 71.192.103.225 (talk)

 * What prevents you from accessing exactly the same article at Java Programming/Syntax? This isn't the Open University. Material which is purely instructional / educational belongs elsewhere. Wikibooks is that place. Chris Cunningham (not at work) - talk 11:25, 13 March 2009 (UTC)

Reverting due to Inconsistency with other existing syntax articles + adding Cleanup

 * I realize that I am raising this point after the recent AfD referenced above, but it seems pretty odd to me that almost each of the widely used prog. languages out there, with an article on wikipedia (C, C++, C#, JavaScript), also have a syntax article in a very similar structure (C# Syntax ...etc) to the previous format/content of this article. Thus, Java is now the only language on wikipedia of the same weight, yet a very lacking syntax page.

 * After reading the AfD, I understand that the argument made to clean/delete this article was based on valid policies such as those included and referenced from (WP: What Wikipedia is not), however, IMO the syntax articles for any of the aforementioned languages, fitting within one page of average length, can never be comprehensive enough to be considered a prescriptive user guide or manual. They are more of a brief overview of the syntactical properties, features and constructs of a language that are usually necessary to enable a basic differentiation between a programming language and another, which can be argued to be the most important part of even a high-level understanding a language. Moreover,  if all the syntax articles are removed or reduced accordingly, where can we for instance point out to language properties such as the immutability of strings in Java, C# or JavaScript vs. C and C++? Such details should not be overloaded at the main language article, and yet can be very much argued to be encyclopedic material essential to give a feeling of programming languages evolution. IMO, that's was one of the reasons the syntax articles were created in the first place, and in their current format. This format may need a cleanup as requested in some syntax articles, but shouldn't be a reason for massive content deletion until proven otherwise.

 * Also, the fact that this content was copied/transwikied into wiki books can be argued to be not a valid justification for content/article deletion. The content was originally in this article and it can be copied and repeated in dozen other sites yet do not pose an obligation to delete it from the article at hand. Particularly, that it even adds to the inconsistency where a user can check the syntax for the majority of the other languages by searching in wikipedia except now for Java.

 * The consensus reached in the AfD was to keep the article with an ongoing debate on rewriting it. Since no consensus have been reached on rewriting the article, and based on other policies such as WP:IMPERFECT and WP:PRESERVE am reverting the article back to its original form and adding a cleanup tag instead to allow the discussion for what to change to continue. Please do not revert back. --K.G. (talk) 23:00, 3 April 2009 (UTC)

 * There's nothing in that comment which justifies the restoration of the previous version, which has inevitably resulted in nine months of edits which have done nothing to address the points made previously regarding the article content. I would implore future editors to work on the Wikibooks article if they believe that the previous content was worthwhile. Chris Cunningham (not at work) - talk 23:01, 27 January 2010 (UTC)

Reverting due to Inconsistency with other existing syntax articles
What kind of argument is that?

If the other existing syntax articles are crap, it does not mean, that this one should be the same.

There is no use of this article at all after the last improvement.

Is the goal of Wikipedia to be understandable to every mere mortal, who has no interest of Java or any other programming language?

Yet I wish you luck and keep administring! --62.65.212.117 (talk) 16:50, 28 January 2010 (UTC)

Wikipedia will end up to be a "rate my contribution" page unless we can get rid of self-admiring moderators.

Whoever was the lord, who replaced the real syntax overview with this tabloid news, please be so nice and think about the interests of users of Wiki and not the virtual career!

I need the information, that was here and not the joke, what has remained.

--62.65.212.117 (talk) 19:13, 28 January 2010 (UTC)

 * What you "need" is available on WikiBooks by following this link. WikiBooks contains a host of information on programming; its purpose is to serve as this sort of repository. Wikipedia is not intended to be everything to everyone; it will tell you what an aircraft is but is not expected to teach you how to fly one. Would that more people in the less-well-travelled parts of the encyclopedia considered this before dumping their life experiences into pages indiscriminately. Chris Cunningham (not at work) - talk 10:44, 29 January 2010 (UTC)

Image of syntax shows a global function
The code shown in the image is not valid Java being that there is no enclosing class - is that appropriate? —Preceding unsigned comment added by 220.237.145.215 (talk) 11:25, 24 February 2011 (UTC)
 * It's not a valid Java program. But it is valid code nonetheless, and it is said that it's just a code snippet. HotXRock (talk) 14:05, 6 April 2012 (UTC)

What import actually does

 * The import statement loads a specific class or classes from a referenced package.

Does import actually load the class, in the sense of adding all the code from the API into your program? Or does it just tell the compiler where to look?

I thought all the compiled code in the API is already in the virtual machine. Someone downloading, say, an applet from a website wouldn't be downloading the entire util package with a statement like

import java.util.*

Is this correct --Uncle Ed (talk) 14:17, 7 March 2012 (UTC)

 * You are right, the  declaration doesn't actually load anything, it only allows to use shorter names for the classes in the file. It doesn't influence the actual code which is produced by a compiler. I'll fix this. HotXRock (talk) 18:54, 7 March 2012 (UTC)

 * Thanks, man, you rock! :-) --Uncle Ed (talk) 22:17, 7 March 2012 (UTC)

Single Element Annotations
According to the JLS 9.7.3, this only works if the omitted element name is 'value'. Seemed to be true when I tested it out. OK to change the wording on this example to use 'value' instead of 'fileSystemOperations'? Along the lines of...
 * The other short form is called single element annotation. It is used with annotation types where one element is named 'value' and all the other elements have default values. In single element annotation :form the element name is omitted and only value is written instead:
 * /* Equivalent for @BlockingOperations(value = true).
 * networkOperations has a default value and
 * does not have to be assigned a value */
 * @BlockingOperations(true)
 * void openOutputStream {"
 * }

Faolin42 (talk) 23:10, 8 October 2013 (UTC)

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: Talk:Java syntax


text:
Brimley, Michigan

Brimley is an unincorporated community and census-designated place (CDP) in Chippewa County in the U.S. state of Michigan. The CDP had a population of 504 at the 2020 census. Brimley is located in Michigan's Upper Peninsula, and is located along the southern shore of Lake Superior. The community is located within Superior Township.

Brimley is home to Brimley State Park and Bay Mills Resort & Casino, the latter operated by the Bay Mills Indian Community. As an unincorporated community, Brimley has no legal autonomy of its own, however it does have its own post office with the 49715 ZIP Code.

History
Brimley was established as a station on the Duluth, South Shore and Atlantic Railway in 1872. The community was platted in 1887, and was given a post office with the name Superior in 1888. The community was renamed to Brimley in 1896.

For the 2020 census, Brimley was included as a newly-listed census-designated place.

Geography
According to the U.S. Census Bureau, the Brimley CDP has a total area of 2.15 sqmi, of which 1.75 sqmi is land and 0.40 sqmi (18.60%) is water.

Brimley is located in the eastern Upper Peninsula, and is located along the south shore of Waiska Bay, a bay of Lake Superior. The mouth of the Waiska River is located within the community. Immediately west of Brimley is the Bay Mills Indian Community, which is home to Bay Mills Resort & Casino and Bay Mills Community College. Immediately east of Brimley is Brimley State Park.

Brimley lies about 11 mi southwest of Sault Ste. Marie.

Major highways

 * is a short north–south route connecting Brimley to M-28, a major east–west state trunkline highway.

Education
Brimley is home to the Brimley Area Schools district, which operates a public school within the community. The school's teams are known as the "Bays".

title: Brimley, Michigan


text:
Don Alden Adams

Don Alden Adams (January 16, 1925 – December 30, 2019) was president of the Watch Tower Bible and Tract Society of Pennsylvania (2000–2014), the principal corporation of Jehovah's Witnesses.

Biography
Born in January 16, 1925 in Oak Park, Illinois, Adams grew up in a big family, which originally had connections to the Episcopal church. His mother showed interest in Jehovah's Witnesses and gradually the children also became interested. His father initially showed no interest, but involved himself in a legal case when one of Don's younger brothers was not exempted from military service, and eventually became a member.

After serving as a full-time preacher, Adams was invited in late 1944 to serve at the world headquarters of Jehovah's Witnesses in Brooklyn, New York,   where he was secretary to Society president, Nathan H. Knorr. By the 1960s, Adams served directly under the Governing Body as a zone overseer, visiting various countries to audit branch offices and meet with Witness missionaries. Later, Adams directed world missionary activities, and served on the "Bethel Home Committee".

In 2000, the New York Daily News described Adams as "a longtime insider ... at the world headquarters in Brooklyn Heights." The Washington Post described Adams as "a 50-year veteran of the organization," which has been restated in subsequent publications. Adams also served on the Publishing Committee.

Watch Tower Society presidency
Adams, a Governing Body "helper", became president of the Watch Tower Society after Governing Body member Milton G. Henschel stepped down from the position in 2000. In that year, members of the Governing Body resigned from their executive positions of the corporations of Jehovah's Witnesses, although the periodical Christianity Today reported that the Governing Body of Jehovah's Witnesses would continue its "oversight" role.

Adams' presidency was administrative, and he is not considered to have impacted the organization's ministry as have past Watch Tower Society presidents. Adams' brother, Joel Cameron Adams, was a vice-president of the Christian Congregation of Jehovah's Witnesses, Inc., a related corporation.

In 2014, Adams was replaced as president of the Watch Tower Society by Robert Ciranko. Adams died in December 2019, at the age of 94.

title: Don Alden Adams


text:
Adrienne Ames

Adrienne Ames (born Ruth Adrienne McClure; August 3, 1907 – May 31, 1947) was an American film actress. Early in her career she was known as Adrienne Truex.

Early years
Ames was born in Fort Worth, Texas, one of six children of Samuel Hugh McClure and Flora Parthenia (née Potter) McClure.

Film
Ames began her film career in 1927 as a stand-in for Pola Negri. Ames was soon cast in small film roles in silent films. With the advent of talking pictures, Ames' popularity grew and she was usually cast as society women, or in musicals. She made thirty films during the 1930s with her biggest success in George White's Scandals (1934). She appeared with the three leading men from the 1931 version of Dracula (Bela Lugosi, David Manners, and Edward Van Sloan) in The Death Kiss (1932).

Radio
Ames left Hollywood for New York. In 1941, she was hostess of two talk shows on station WHN in New York City. Her schedule included broadcasts at noon and 3:30 p.m. six days a week and 7:30 p.m. broadcasts on Tuesdays, Thursdays, and Saturdays. She continued broadcasting until two weeks before her death in 1947.

Television
In December 1941, Ames began a weekly series of movie-review programs on WNBT in New York City. The 10-minute programs ran on Tuesday afternoons.

Personal life
Ames was married three times. In 1920, at the age of 13 or 14, she married Derward Dumont Truax, the son of an oil businessman. They had a daughter, and divorced in 1924. A later marriage to broker Stephen Ames ended in divorce on October 30, 1933. Her last marriage, on October 31, 1933, was to fellow actor Bruce Cabot; they divorced on July 24, 1935.

Death
Ames died of cancer on May 31, 1947, in New York City, aged 39. She is interred in the Oakwood Cemetery in her hometown of Fort Worth, Texas.

For her contributions to the film industry, Ames has a motion pictures star on the Hollywood Walk of Fame at 1612 Vine Street. It was dedicated February 8, 1960.

title: Adrienne Ames