CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ

Java

Java Programming
Basic coding skills
Code identifiers

The rules for naming an identifier

  • An identifier is any name that you create in a Java program. These can be the names of classes, methods, variables, and so on.
  • Start each identifier with a letter, underscore, or dollar sign. Use letters, dollar signs, underscores, or digits for subsequent characters.
  • Use up to 255 characters.
  • Don't use Java keywords.
  • Remember that Java is a case-sensitive language.

Valid identifiers

InvoiceApp $orderTotal i
Invoice _orderTotal x
InvoiceApp2 input_string TITLE
subtotal _get_total MONTHS_PER_YEAR
discountPercent $_64_Valid

Keywords

A keyword is a word that's reserved by the Java language. As a result, you can't use keywords as identifiers.

boolean if interface class true
char else package volatile false
byte final switch while throws
float private case return native
void protected break throw implements
short public default try import
double static for catch synchronized
int new continue finally const
long this do transient goto
abstract super extends instanceof null

Previous | Code statements | Code comments | Code identifiers | Declare a class | Declare a main method | Next