Core Java Tutorials


Introduction

Java Hello World

Java Compilation

JDK New Features

JVM Architecture

Java OOPs Concepts

Java Package

Array

Exception Handling

String

Immutable Class

File Handling

Serialization

MultiThreading

Volatile

Concurrent Package

Collection

Collection Internal

Generics

Cloning

Reflection In Java

Annotation

Class Loader

Java Inner classes

Garbage Collector

JDBC

References In Java

Heap Dump & Thread Dump

Instance Variable in java

Instance variable in java are associated with instance of class and declared in a class, but outside a method, constructor or any block. Instance variables holds state of an object. Memory of instance variables are allocated only when object is created. These are called instance variables because their values are instance specific and are not shared among instances.


instance-variable-in-java
 Java Instance Variable Example
instance-variable-example

In above picture we are creating two instances of ConnectionPool type class. So every instance or object will have it's own copy of instance variable like max, min, name and idleTime. Instance variables hold current state of an object and it's also drives the behavior of an object. In other words if you change the state of any object then it;s behavior will also be change.