Java variable_basic rule

2020. 12. 28. 19:10Java/English

  • Java has containers for storing data values which called containers.

  • Each Variable can only contain one data type.

For example, this typical type of variable shows the basic information:

 

int num = 1;

int: specific data type

num: name of the variable

=: Operator (which it would be shown later)

1: initial value

 

Declaring variables does not directly mean equal as the symbol "=" shows, declaring variables means a substitute.

 

Java's rule for declaring variables

There are several rules to declare or write variables.

  1. The name of the variable cannot start with a number and special characters can only allow using "$" and "_". Java differentiates the uppercase letters and  lowercase letters (in other words variables "num" and "Num" are different variables.
  2. Hungarian type: In order to distinguish each word it adds a prefix start of each word (for example, int iNum, char cHead)
  3.  Camel notation: The start of each and every word starts with an upper case (int myPerson)
  4. Pascal notation: Similar to camel notation. The first letter at every word starts with an upper case 

 

 

 

 

 

 

'Java > English' 카테고리의 다른 글

Java variable_2_Primitive Data type  (0) 2020.12.30