.java
extension. When you compile the java program Those source files are then converted into .class
files by the javac
compiler. A .class
file does not contain code that is native to your processor; it instead contains bytecodes Java VM is available on many different operating systems, the same
.class
files are capable of running on Microsoft Windows, the Solaris TM Operating System (Solaris OS), Linux, or Mac OS.Identifiers and Keywords
The rules the compiler uses to determine whether a name is legal.
- Identifiers must start with a letter, a currency character ($), or a connecting character such as the underscore ( _ ). Identifiers cannot start with a number!
- After the first character, identifiers can contain any combination of letters, currency characters, connecting characters, or numbers.
- In practice, there is no limit to the number of characters an identifier can contain.
- You can't use a Java keyword as an identifier.
- Identifiers in Java are case-sensitive; foo and FOO are two different identifiers
The following identifiers are legal
int _a; //starting with underscore
int $c; //starting with $ sign
int ______2_w; //starting with underscore
int _$; //starting with underscore
int this_is_a_very_detailed_name_for_an_identifier; // starting with a letterThe following identifiers are illegal
int :b; // starting letter is not valid
int -d; // starting letter is not valid
int e#; // special charactor # is not legal
int .f; // starting (.) is not valid
int 7g; //starting with number not allowed.
Java Keywords
You cannot use any of the following as identifiers in your programs
abstract | continue | for | new |
switch | assert*** | default | goto* |
package | synchronized | boolean | do |
if | private | this | break |
double | implements | protected | throw |
byte | else | import | public |
case | enum**** | instanceof | return |
transient | catch | extends | int |
short | try | char | final |
interface | static | void | throws |
class | finally | long | strictfp** |
volatile | const* | float | native |
super | while |
* not used** added in 1.2 *** added in 1.4 **** added in 5.0
Through the Java VM, the same application is capable of running on multiple platforms.
Legal Identifiers
Technically, legal identifiers must be composed of only Unicode characters, numbers, currency symbols, and connecting characters (like underscores).
All the Java components —classes, variables, and methods—need names. In Java these names are called
there are rules for what constitutes a legal Java identifier.