About Class Or Static Variable In Java Programming

In this tutorials we will discussed more about variables in java programming of Class Or Static. 

Types of variables:

Class Or Static 
Instance 
Local
Parameters Or Arguments 

What we need before start the code, I'm using as mention below and already installed in my system:
1. JDK1.6 or +
2. Eclipse
3. Windows OS
4. Basic knowledge of java

Let's start:




Verify the JDK installation


Open the command prompt and verify the java installation
Type the 
C:\>javac -version
javac 1.7.0_25

C:\>java -version

java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

Now java installation got verified, as installed JDK1.7.0_25

Verify the Eclipse installation

Go the the installation directory of eclipse and click on the eclipse.exe
e.g C:\eclipse\eclipse-java-mars-1-win32\eclipse\eclipse.exe


Create the new java project in Eclipse


Open the eclipse

File
New
Java project
Type the project name: Variables_In_Java_Programming
Next
Finish

Create the ClassOrStaticVariablesInJava.java file


Right click on the src created under project Variables_In_Java_Programming

New
Class
Type the name of class: ClassOrStaticVariablesInJava
Type the package name: com.variables.atozexamples
Finish

package com.variables.atozexamples;

public class ClassOrStaticVariablesInJava {

       // Class or Static variable
       public static int iClassOrStaticVarible = 1;

       // Class or Static variable as final, we can't change the value and name
       // must be in capital
       public static final int I_CLASS_OR_STATIC_FINAL_VARIBLE = 200;

       public ClassOrStaticVariablesInJava() {
              // TODO Auto-generated constructor stub
       }

       public static void main(String[] args) {
              // Class level access
              System.out.println("Output of Class or Static Variable value = " + I_CLASS_OR_STATIC_FINAL_VARIBLE);
              System.out.println("Output of Class or Static Variable by obj value =" + iClassOrStaticVarible);

              // New object creation of ClassOrStaticVariablesInJava
              ClassOrStaticVariablesInJava obj = new ClassOrStaticVariablesInJava();

              // Calling with obj
              System.out.println("Output of Class or Static Variable by obj value =" + obj.iClassOrStaticVarible);
              System.out.println("Output of Class or Static Variable by obj value =" + obj.I_CLASS_OR_STATIC_FINAL_VARIBLE);
             
              iClassOrStaticVarible = 300;
             
              System.out.println("Output of Class or Static Variable by obj value =" + obj.iClassOrStaticVarible);
             
              System.out.println("Output of Class or Static Variable by obj value =" + iClassOrStaticVarible);

       }

}


All about Class Or Static variables in java programming.

1 comment:

  1. Python programming | tutorial for beginners full course
    #python #corepython #tutorial #beginners

    Welcome to this full course where you will learn python for beginners. In this python for beginners course I will learn you python and give you a better understanding of the core concepts about python and its programming. Python is cool, easy and powerful programming language.

    Feel free to enrol to this course as mentioned below so you can follow each video in single place.

    1, 2, 3 go...

    ► Enrol here https://www.udemy.com/course/core-python-programming-by-examples/?referralCode=DF6FEF13CE558ED36D82

    Table Of Contents

    Introduction
    Installing Python
    Installing Pycharm
    Your first Python program
    Variables
    Creating Variables
    Naming Variables
    Data Types
    Dynamically Type Language
    Comments
    Strings
    Multiline and Formatting Strings
    Indentation
    Arithmetic Operators
    Comparison Operators
    Logical Operators
    Assignment Operators
    Controll Structure: If Statements
    If-elf Statements
    Lists
    Useful List Methods & Deleting Items from Lists
    Sets & Set Union Intersection & Difference
    Dictionaries
    Python Loops
    For Loop
    While Loop
    Break and Continue
    Functions
    Parameters and Arguments
    Return Values From Functions
    Built in Functions and Import Statement
    Creating Modules
    Classes and Objects
    Creating Classes and Objects
    Printing Objects
    Creating Files
    Modules

    Subscribe to

    ► Join Private Facebook Group - https://www.facebook.com/groups/577467286228301

    ❤️ Thanks for watching

    ReplyDelete