Class VariableDeclarator

java.lang.Object
com.github.javaparser.ast.Node
com.github.javaparser.ast.body.VariableDeclarator
All Implemented Interfaces:
NodeWithRange<Node>, NodeWithSimpleName<VariableDeclarator>, NodeWithTokenRange<Node>, NodeWithType<VariableDeclarator,​Type>, Observable, Visitable, HasParentNode<Node>, Resolvable<ResolvedValueDeclaration>, Cloneable

The declaration of a variable.
In int x = 14, y = 3; "int x = 14" and "int y = 3" are VariableDeclarators.

The type is on all of the variable declarators because, thanks to array brackets, each variable can have a different type.

Author:
Julio Vilmar Gesser
  • Constructor Details

    • VariableDeclarator

      public VariableDeclarator()
    • VariableDeclarator

      public VariableDeclarator(Type type, String variableName)
    • VariableDeclarator

      public VariableDeclarator(Type type, SimpleName name)
    • VariableDeclarator

      public VariableDeclarator(Type type, String variableName, Expression initializer)
    • VariableDeclarator

      public VariableDeclarator(Type type, SimpleName name, Expression initializer)
      Defines the declaration of a variable.
      Parameters:
      name - The identifier for this variable. IE. The variables name.
      initializer - What this variable should be initialized to. An AssignExpr is unnecessary as the = operator is already added.
    • VariableDeclarator

      public VariableDeclarator(TokenRange tokenRange, Type type, SimpleName name, Expression initializer)
      This constructor is used by the parser and is considered private.
  • Method Details