Java: $NON-NLS-1$

Look at this snap:

public static String valueOf(boolean value) {   
        return value ? "true" : "false"; //$NON-NLS-1$ //$NON-NLS-2$
}    

What is "//$NON-NLS-1$ //$NON-NLS-2$" mean ?

It's used by Eclipse to indicate that a string doesn't need to be translated, probably because it's not going to be seen by the application's users. Netbeans uses NOI18N for the same purpose.

If you don't add that, you'll get a compiler warning. It doesn't stop your code from compiling into a valid class file, but it tells you that you may be doing something undesirable. You are free to ignore the warning. But if you don't want to see it at all--perhaps because too many warnings about something that you're doing on purpose clutters up the output and obscures warnings you do care--then you can add that $NON-NLS-1$ to tell the compiler not to produce the warning.

It's just about fine-tuning which warnings you do and do not care to see.

你可能感兴趣的:(java,eclipse,NON-NLS-1$)