Java   View all facts   Glossary   Help
syntactic unit > declaration
Next syntactic unitdefinition    Upsyntactic unit    Previous syntactic unitcomment   

declaration comparison table
Subject define have syntax terminate by be is a kind of is a synonym of is a subtopic of have example place occur create locate have purpose import be part of has definition declare contain
array declaration  square brackets following the type  declaration Arrays
int[] anIntArray = new int[25];
byte[] aByteArray; // not initialized
Account[] anAccountArray = new Account[numAccounts];
      definition   
class declaration 
public abstract final class nameOfClass extends Super implements Interfaces
  declaration Classes
public class HelloWorld
    to specify the class definitionA declaration that specifies a class and does not include the class body the class name
import statement  
import packageName.*
OR
import packageName.className
a semicolonnot more than one line long if possiblestatementimport declarationPackages
//Import the Circle class from the graphics package
import graphics.Circle;

//Import the entire graphics package
import graphics.*;
   to allow a class to use the facilities of another package1 member class of a package or imports on demand 0 or more member classes from a packagedefinitionA statement that permits using references to other packages without prefixes  
interface declaration  
public interface interfaceName extends superInterfaces 
  declaration Interfaces
public class AnimatedSign extends javax.swing.JApplet
    to declare an interface 1 interface definition  
method declaration the method
accessLevel static abstract final native synchronized returnType methodName (parameterList) throws exceptions
  declaration Methods
int[] makeRange(int lower, int upper) 
    to declare a method definition   
object declaration  
type name
where type may be the name of a class or an interface
  declaration Objects
Rectangle rect; 
  a new object to declare an object, without actually creating it definition   
package statement  
package packageName
a semicolonthe first statement in the source file except for commentsstatementpackage declarationPackages
package com.naviseek.canasta
 at the beginning of a file  to specify the name of the package to which the compilation unit in which the package declaration is put belongs definitionA statement that declares the name of the package the file defines package information about the class in the source file
parameter declaration  
type parameterName
  declaration Variables and Data Types     to declare a parameter definition   
variable declaration  
accessLevel static final transient volatile type variableName
  declaration Variables and Data Types
Rectangle rect = new Rectangle(); 
practically anywhere in Java source code although it is good practice to only declare variables at the beginning of blocks   to declare a variable definition  the type name and the variable name

Next syntactic unitdefinition    Upsyntactic unit    Previous syntactic unitcomment