parst into
parsed into
parsed into
parsed into
parsed into
parsed into

medthod Declaration

Method modifier

static

Method header

Result

float

MethodDeclaration

identifier

JVletter

'm'

JVletterorDigit

'i','n'

fomalParameter

UnnaType

int[]

variable declaratorID

a

Method body

blockstatement

comment

//TODO: implement this

Sujet principal

EX2: static float min(int[] a) {
// TODO: implements this
}

Method Declaration

Method Modifier

static

Method Header

Result

int

Method Declarator

identifier

identifierChar

nextCount

fomalParameterList

unannType

UnannPrimitiveType

int

VariableDeclaratorld

iidentifier

i

Method Body

block

blockStatement

LocalVariabeDeclarationStatement

LocalVảiableDeclaration

UnannType

UnannPrimitiveType

int

LocalVariableDeclarationList

VariableDeclarator

VariableDeclaratorld

j

VariableInitializer

expression

i+1

returnStatement

return j

EX3: static int nextCount(int i) {
int j;
{ j = i + 1;
}
return j;
}

Method Declaration

MethodModifier

private static

MethodHeader

result

float

MethodDeclarator

identifier

identifier

identifierChar

JVLetter

'm'

JVLetterorDigit

'i','n''

FormalparameterList

FormalParameter

VariableModifier

UnannType

UnannPrimitiveType

NumericType

float

VariableDeclaratorld

identifier

a

formalParameter

UnannType

UnannPrimitiveType

NumericType

float

VariableDeclaratord

identifier

b

MethodBody

block

blockStatement

LocalVariableDeclarationStatement

LocalVariableDeclaration

UnannType

UnannPrimitiveType

float

VariableDeclarationList

VariableDeclarator

VariableDeclaratorld

min

ReturnStatement

return min

EX4: private static float min(float a, float b) {
float min;
min = a <= b ? a : b;
return min;
}

Method Declaration

MethodModifierr

private static

MethodHeader

result

float

MethodDeclarator

identifier

idnetifierChá

JVletter

'm'

JVletterorDigit

'i','n'

FormalParameterList

FormalParameter

unannType

float

Variabledeclaratorid

a

FormalParameter

unannType

float

VariableDeclaratorld

b

MethodBody

block

blockStatements

blockStatement

localDeclarationStatement

localVariableDeclaration

unannType

float

VariableDeclarationList

VariableDeclarator

VariableDeclaratorld

'min'

IfStatement

IfthenElseStatement

relationExpression

expression

a<=b

assignment expression

expressionStatement

min =a

min=b

returnStatement

return min

EX5: private static float min(float a, float b) {
float min;
if (a <= b) {
min = a;
} else {
min = b;
}
return min;
}

Method Declaration

Method Modifier

static

Method Header

réult

int

MethodDeclarator

identifier

identifierChars

search

forrmalParameterList

FormalParameters

formalParameter

unannType

unannPrimitiveType

numericType

int[]

VariableDeclaratorld

identifier

a

formalParameter

int x

Method Body

block

blockStatement

ForStatement

localVariableDeclaration

unannType

unannprimitiveType

int

forInit

i=0

relationexpression

expression

i< a.length

unaryexpression

forupdate

i++

IfStatement

ifthenStatement

expressionStatement

expression

x==a[i+0]

returnStatement

return i

returnStatement

returnexpression

-1

EX5 static int search(int[] a, int x) {
for (int i = 0; i < a.length; i++) {
if (x == a[i+0]) return i;
}
return -1;
}

Method Declaration

Method Modifier

public static

Method Header

result

void

MethodDeclarator

identifier

main

formalParameterList

unannType

String[]

variableDeclaratorld

args

Method Body

block

blockStatement

localVariableDeclarationStatemetn

localVariableDeclaration

unannType

int[]

int

int

VariableDeclaratorList

variableDeclarator

variableDeclaratorld

a

x

isAt

VariableInitialiser

{1,1,2,3,5,8,13}

methodInvocation

typeName

TextIO

search

identifier

getInt

argumentList

'x','a'

public static void main(String[] args) {
int[] a = {1, 1, 2, 3, 5, 8, 13};
int x = TextIO.getInt();
int isAt = search(a, x);
System.out.printf("%d is in %s at %d", x, a, isAt);
}