Skip to main content

Best Programming Channel. What is variable and its types, Clear Your Con...


Variables



The variable in Java is a memory location which used to stores the data values during Java program execution. Every variable has a data type that defined the type and quantity of data that hold data. variable used to store data temporarily. The name of the variable cannet be changed but the value of the variable.
Declaration of variables in java
Syntax 
 type        Variable Name  = Value;
       ↘                            ↘ variable name 
     Data type like int,             Like a,b
     string, char
Example 1:
     Create a variable called the ’ Student Name’ of type String and assign it the value "Ahmad Mukhtiar":  
String Student Name =” Ahmad Mukhtiar”;  
System.out.println(“Student Name”,+Student Name);
  Example 2:
Create a variable called ‘Roll No’ of type int and assign it 50: 
int Roll No=50;
System.out.println(“Your Roll No “+Roll No);   
Example 3:
You can assign value later declare a variable without assigning a value
Int a ;
a=10;
System.out.println(The value of a=”+a);
You can assign a new value to exist it will overwrite the previous value


Int a=40;
a=30;
System.out.println(“overwrite the value is “,+a);
Types of Variables 

There are their types of variable

1)Instance variable
2)Static variable 
3)Local variable 


1)Instance Variable 

A variable declared outside the method but inside the class is called instance variable 
It not declared with the static keyword.



2)Static variable

A variable declared with a static keyword is called a static variable.
A single copy of a static variable can  you create and share among all the instance of the class 
When class is loaded in memory at this time static variable happens.




3)Local Variable

A type of variable that declared inside the method is called local 

Variable. You can access the local variable only inside the method.
You cannet use the “static” keyword with the local variables.



To Visit the fellowing programming for better understating.
Programs No1.



Class A{
Int a=20;
Static int b=50;
Void method()
{
Int c=40;
system.out.println(“Sum of instance ,static and local variable are =”+a+b+c);
}
Public static void main(String[]  args){
method();
}
}
Programs NO 2:
  1. Class ADD{  
  2. public static void main(String[] args){  
  3. int y=100;  
  4. int x=40;  
  5. int z=y+x;  
  6. System.out.println(z);  
  7. }}  





Comments

Popular posts from this blog

Assistive Technology Tools & Resources For College Students With Disabilities

                                                                   Assistive innovation devices are among the least 'celebrated' however most pivotal apparatuses in K-12 instruction today.  As indicated by the National Education Association (NEA), the quantity of U.S. understudies took a crack at a custom curriculum program has risen 30 percent in the course of the last 10 years. Additionally, the NEA reports that almost every broad training homeroom in the nation incorporates understudies with handicaps, as three out of each four understudies with incapacities spend part or the entirety of their school day in overall instruction study hall.  One apparatus to assist understudies with handicaps even notwithstanding a specialized curriculum instructor deficiency is assistive innovation. Today, assistive innovati...

How long will the COVID 19 last?

fasmart1.blogspot.com CORONA VIRUS One of the incredible inquiries with COVID 19 is the manner by which long is this going to last and any individual who asserts that they know the response to that it's tricking you. Basically put we don't have the foggiest idea whether this infection is occasional, If you take a gander at crown  infections by and large some of them are occasional however we likewise have ones like meres-inlet that we know is amazingly impervious to warm so that this infection will vanish in April or May when it starts to heat up we just don't have the foggiest idea about the response to that reality so how long is it going to take? What we expect as disease transmission specialists will happen is the infection will gradually circle through the network at one point we will get what we call group resistance and crowd invulnerability implies we've contaminated such a large number of individuals that when the infection experiences individuals th...

Best Programming Channel.How to Install eclipse and Create Your First Pr...

fasmart1.blogspot.com