Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all numeric literals in Java code

Tags:

java

eclipse

I am supporting external code and I want to extract all constants and magic numbers from the code. Is there any fast way of doing it in Eclipse?

like image 880
MLProgrammer-CiM Avatar asked Oct 17 '12 14:10

MLProgrammer-CiM


People also ask

What is numeric literals in Java?

An exact numeric literal is a numeric value without a decimal point, such as 65,– 233, and +12. Using the Java integer syntax, exact numeric literals support numbers in the range of a Java long. An approximate numeric literal is a numeric value in scientific notation, such as 57.,– 85.7, and +2.1.

What are the five 5 literals in Java?

There are five major literal types in Java: Boolean (boolean), integer (int), character (char), string (string), and floating-point (float and double) literals.

How many literals are there in Java?

Literals in Java can be classified into six types, as below: Integral Literals. Floating-point Literals. Char Literals.


1 Answers

I've used PMD, an code static analysys tool, that can work as an Eclipse plug-in. It will flag magic numers so you don't have to look for them yourself.

like image 181
Tulains Córdova Avatar answered Oct 10 '22 03:10

Tulains Córdova