Tuesday 17 October 2017

Variable in java

Variable in java:-
                      Variable is an identifier which holds data or another one variable is an identifier whose       value can be changed at the execution time of program. Variable is an identifier which can be used           to identify input data in a program.
       






Syntax :-
                   Variable_name =value;

Rules to declare a Variable:-

  • Every variable name should start with either alphabets or underscore ( _ ) or dollar ( $ ) symbol.
  • No space are allowed in the variable declarations.
  • Except underscore ( _ ) no special symbol are allowed in the middle of variable declaration
  • Variable name always should exist in the left hand side of assignment operators.
  • Maximum length of variable is 64 characters.
  • No keywords should access variable name.
Note: Actually a variable also can start with ¥,¢, or any other currency sign.
Example:-
class Sum
{
 public static void main(String[] args) 
  { 
   int _a, ¢b, ¥c, $d, result;
   _a=10;
   ¢b=20;
   ¥c=30;
   $d=40;   
   result=_abc+$d; 
   System.out.println("Sum is :" +result);
  }
}

No comments:

Post a Comment

Data Conversion in java

Data Conversion In java programming we have six data conversion technique they are:. 1 Converting numeric string type data into numeri...