CodesJava

Easy learning with example program codes

variable and datatypes in java


Variable:  

Variable is the name of reserved memory location. It means when we declare a variable some part of memory is reserved.

e.g. int var1 = 35;

var1 is a variable here.

Variable Types:  

variable types

 

Local variable:

A variable that is declared within the method, constructor, or block is known as local variable.

No Access modifier is used for local variables. Scope of local variable is limited to that method, constructor, or block only in which it declared.

Instance variable:

A variable that is declared within the class but outside of method, constructor, or block is known as instance variable (Non static). They are associated with object. Access modifiers can be used with instance variables. Inside class you can access instance variable direct by variable name without any object reference.

Static variable:

A variable that is declared within the class with static keyword but outside of method, constructor, or block is known as Static/class variable. They are associated with class. Static variable are accessed by ClassName.VariableName.

 Data types:

As we discussed when a variable is declared some part of memory is reserved. But how much memory will be reserved. It depends upon the data type of the variable.  i.e. how much memory will be reserved and which type of data can be stored in reserved memory is depends upon data type of the variable.

Primitive data types:

Primitive data types are predefined in the language.

data types

 
Next Topic: Hello world java program.
Previous Topic: Some important definitions for java programs.

Related Topics:

Some important definitions for java programs.
Variable and data types.
Hello world java program.
Important Java Programs.
How to set permanent path in java?

 

Posted in Java   

Core Java Tutorial

Programming language overview.
Overview of Java.
Java features
JVM architecture details.
JVM, JRE and JDK.
Java Coding Guidelines.
Some important definitions.
Variable and data types.
Hello world java program.
Core java examples programs.
Important Java Programs.
How to set permanent path in java?
OOPs Basics.
Object and Class in Java.
OOPs Principles/Concepts.
Abstraction in java.
Encapsulation in java.
Polymorphism in java.
Method overloading in java.
Method overriding in java.
Dynamic method dispatch.
Runtime polymorphism.
Association in java.
Inheritance in java.
Aggregation in java.
Command line arguments in java.
Command line argument program in eclipse.
Read input from command line using Scanner.
Java array programs
Java star pattern programs
Java number pattern programs
final in java.
Abstract class in java.
Interface in java.
Custom marker Interface in java.
Constructor in java.
Package in java.
Access modifier in java.
Static import in java.
Package class in java.
this in java.
Instance initialize block.
Anonymous block.
super in java.
Static in java.
final in java.
Java cloning deep and shallow
Shallow vs Clone copy
String handling in java.
String handling programs.
StringBuffer in java.
StringBuilder in java.
Exception Handling Tutorial.
Multithreading Tutoial.
Java input output stream tutorial.
Collections framework in java tutorial.
Collections framework programs.
Java Random class
Java annotations.
Java design principles.
Java 7 features
Java 8 features
Java networking tutorial
Java Reflection tutorial


Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap