Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard in java for _ (underscore) in front of variable or class names?

Tags:

I have seen some programmers using _ (underscore) in front of class names, and others using it for local variables.

Does the Java standard require/suggest the use of _ (underscore) in front of an private instance variable or class name?

like image 601
Ashok Koyi Avatar asked Dec 14 '09 08:12

Ashok Koyi


People also ask

Can a variable name start with _ in Java?

A variable's name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign " $ ", or the underscore character " _ ". The convention, however, is to always begin your variable names with a letter, not " $ " or " _ ".

Can we use _ in Java?

The use of the variable name _ in any context is never encouraged. The latest versions of Java reserve this name as a keyword and/or give it special semantics. If you use the underscore character (“_”) as an identifier, your source code can no longer be compiled. We will get a compile-time error.

Can a variable start with a _?

Go variable naming rules: A variable name must start with a letter or an underscore character (_) A variable name cannot start with a digit. A variable name can only contain alpha-numeric characters and underscores ( a-z, A-Z , 0-9 , and _ )

What does _ in front of variable mean?

A single leading underscore in front of a variable, a function, or a method name means that these objects are used internally.


1 Answers

I think artifacts like these are pre-IDE and C++ vintage. Don't do it.

like image 162
duffymo Avatar answered Oct 03 '22 23:10

duffymo