Data Types and variables in Java

datatypes

Data Types

  • The term data type refers to the type of data that can be stored in a variable.
  • Sometimes,java is called a "strongly typed language"because when you declare a variable,you must specify the variable's type.
  • Then the compiler  ensures that you don't try to assign data of the wrong type to the variable. 

Variables

Variable is name of reserved area allocated in memory
There are 3 types of  variables in Java
  1. Local variable
  2. Static variable
  3. Instance Variable.
Local Variable
A variable that is declared inside the method is called local variable.

Static Variable
A variable that is declared as static is called static variable. It cannot be local.


Instance Variable
A variable that is declared inside the class but outside the method is called instance variable.
It is not declared as Static.
SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

2 comments: