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

Alpha Android 1.0

fasmart1.blogspot.com  launch to Android 1.0                                                                                                                                                         I n 2007, Apple propelled the first iPhone and introduced another period in portable registering. At the time, Google was still secretly working on Android, but in November of that year, the company slowly began to unveil its plans to tackle Apple and other mobile platforms. It used its structure as an open handset alliance, which included carriers including phone makers such as HTC and Motorola, chip manufacturers such as Qualcomm and Texas, and T-Mobile.                                                                                                                                                                                                       2007  میں ، ایپل نے پہلا آئی فون چلایا اور پورٹیبل رجسٹریشن میں ایک اور مدت متعارف کروائی۔ اس وقت ، گوگل ابھی بھی خفیہ طور پر اینڈروئیڈ پر کام

Educational Technology

fasmart1.blogspot.com Educational technology is the investigation and moral act of encouraging learning and improving execution by making, utilizing, and overseeing fitting mechanical procedures and assets. Top Educational Technology Trends  Instruction is progressively arising to be leading edge. All the items that are happening within the realm of innovation are straight forwardly affecting instruction and learning frameworks. Why this may undoubtedly occur, how our educators, students, and instruction frameworks generally are staying up with them, may be a major concern. Here we are going to acquaint 6 innovative methodologies with instruction.   1. Custom Learning Experiences   Learning techniques and encounters should never be the equivalent for everyone, except the previous instruction frameworks would never oblige the custom learning experience as there have been such an out sized number of impediments. On account of current innovation in training, we are able to truly start cus

Agriculture Technology

fasmart1.blogspot.com There are an expected 570 million ranches on the planet and in a flawless touch of number collaboration, as per Val-oral Advisors, financing adjusts in mechanical developments in horticulture and along the food esteem chain likewise brought around $570 million up in 2014 .  While a lot of this venture is aimed at ag-tech new businesses and problematic market newcomers, from numerous points of view needs continue as before as could be – advancement in asset use, particularly regarding area and water (likewise vitality), to support productivity and yields. Here are five of the farm tech arrangements assisting with supporting worldwide development of practical farming and food creation.  1. Information saved in soil   For conventional cultivating models , maybe the essential determinant of flexibly limit is basically the accessibility and appropriateness of land. Be that as it may, any thought of future potential must be based on current information, with what inf