How to Count Lines in a Java Project
Individual lines of code in a Java project may actually all be part of a "line" in the programming sense, depending on how your project is laid out. Knowing how many actual lines are in your application from a programming perspective is critical for developing more efficient and smaller applications. You can use a feature within Java to print out a line number total in any particular program.
Instructions
-
-
1
Open the Java source code file that you want to count the lines.
-
2
Scroll to the end of the file and create one new line at the end of the file, after the main code.
-
-
3
Type "print->output(this.lncnt)" into the new line, then save the file and execute it. A count of the number of lines in the program -- minus the line that performs the calculation -- is displayed.
-
1
References
- Java The Complete Reference, 8th Edition; Herbert Schildt