About Local Variable In Java Programming
About Instance Variable In Java Programming
About Class Or Static Variable In Java Programming
About Parameters Or Arguments Variable In Java Programming
All Variables in single example:
Create the Java Project in Eclipse and user the below VariablesInJavaProgramming.java code:
Open the eclipse and click on the File
New
Project
Java Project
Next
Enter the Project Name: Variables_In_Java_Programming
Choose the Java Project
Click on the next
Next
Finished
New
Project
Java Project
Next
Enter the Project Name: Variables_In_Java_Programming
Choose the Java Project
Click on the next
Next
Finished
package com.variables.tutorialbyexample;
public class VariablesInJavaProgramming {
// Declared and instantiated with 100 value
// This is also called as filed.
private int iInstanceVariables = 100;
// 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;
// Default Constructor
public VariablesInJavaProgramming() {
}
// Constructor parameter
public VariablesInJavaProgramming( int iParameterOrArgument) {
// Overriding the value of iInstanceVariables by iParameterOrArgument
// value.
this .iInstanceVariables = iParameterOrArgument;
}
private void print(Object oParameter) {
Object oLocalVaribles = oParameter;
System. out .println(oLocalVaribles);
}
public static void main(String[] args) {
VariablesInJavaProgramming objVariablesInJavaProgramming = new
VariablesInJavaProgramming();
objVariablesInJavaProgramming
.print("Hello iInstanceVariables you have value ="
+ objVariablesInJavaProgramming.iInstanceVariables);
objVariablesInJavaProgramming.iInstanceVariables = 300;
objVariablesInJavaProgramming
.print("Hello iInstanceVariables you have value ="
+ objVariablesInJavaProgramming.iInstanceVariables);
objVariablesInJavaProgramming.print("Hello iClassOrStaticVarible you have value =" + iClassOrStaticVarible);
objVariablesInJavaProgramming.iClassOrStaticVarible = 2004;
objVariablesInJavaProgramming.print("Hello iClassOrStaticVarible you have value =" + iClassOrStaticVarible);
VariablesInJavaProgramming objVariablesInJavaProgrammingOne = new
VariablesInJavaProgramming();
objVariablesInJavaProgrammingOne.print("Hello iClassOrStaticVarible you have value =" + iClassOrStaticVarible);
objVariablesInJavaProgramming
.print("Hello I_CLASS_OR_STATIC_FINAL_VARIBLE you have value =" + I_CLASS_OR_STATIC_FINAL_VARIBLE );
VariablesInJavaProgramming objVariablesInJavaProgrammingTwo = new
VariablesInJavaProgramming(500);
objVariablesInJavaProgrammingTwo.print("Hello iInstanceVariables you have value ="
+ objVariablesInJavaProgrammingTwo.iInstanceVariables);
objVariablesInJavaProgramming = null ;
objVariablesInJavaProgrammingOne = null ;
objVariablesInJavaProgrammingTwo = null ;
objVariablesInJavaProgrammingTwo.print("Hello iInstanceVariables you have value ="
+ objVariablesInJavaProgrammingTwo.iInstanceVariables);
}
}
This is all about Variable in Java programming.
Please like and share it, if you like my tutorial and Video.
No comments:
Post a Comment