hi , i want to ask if some one know how can i calculate number of variables or used variables in a java file?
is there any way to do it?

Are you asking for the information that would be shown in a variable cross reference listing if the compiler were to generate such a thing?

You'd need a java language parser to scan the source and generate a cross reference.

or, if you mean you want to know how many instances are made from a certain object, use a static counter.

what i'm asking about is if i have a code just like this one

int x=5;
int y=4;
int z=x+y;
//////

is there any way to get for example : number of integer = 3 ???
without use scanner or any thing like it?

scanner won't help you detect that. if that is what you were looking at, NormR1 is right and you'll have to parse your java code.

what exactly do you need this for?

i need it in my senior program that's all ... ok thx for u and for him ^_^

Another possibility would be to compile the source into a .class file and read that file. It has a well defined format that you could scan for variable definitions. Look at the language definition doc.