# Count the score of a Code Golf code [duplicate]

My challenge is to make a Java method(s) that is given a String (another code in Java), removes any unnecessary characters, counts and returns the score, and displays the cleaned-up code in a way that can be copied/pasted.

It should ignore spaces, line breaks, etc. unless they are necessary to the code.

For example, if the space in the string int number=3; was removed to make it intnumber=3; (and remove a bit), there would be a compiler error if the counted program were run. However,

int
number   =

3           ;


would return 13, the same as the previous two examples.

The program with the least characters as calculated by the program you write (note - this does not mean you can just make it return 0; or something like that) wins!

Note - the code must be in Java. This Java code cannot call code of another language. If there is a loophole, please ask in a comment before posting an answer!

Note: there are a few key differences between this challenge and the other one:

• You have use Java
• You must return the number of characters after having removed spaces, etc.
• You leave the variable names, etc. as are. For this, the score should ignore line breaks, spaces, and other characters skipped over by the compiler when counting. The other program required you to reduce variable names, remove comments, etc.

To be clear, this is primarily a score checker. The code reducing in this program is to help the user get a lower score without substantially changing their program.