Wednesday, 30 March 2016

Variable Declaration and Initialization in Java

Problem:- Variable declaration and initialization in java. How to initialize and declare variables in Java or declaration of variables in java or variable initialization in java. Please read all rules for Variable Declaration and Initialization carefully cause Java is a case-sensitive language so one mistake can be the cause of hundreds of error.

Rule for Variable Declaration And Initialization


1. Import All Necessary Header File Or Library Or Package What Ever You Called them.

2. Class Name Should Contain Only Alphabet ( Upper & Lower Case ) Or _ ( Underscore )

3. Class Name And Java Program Name Should Be Shame Name Ex: Class hello And When You Save The Program It Should Be hello.java

4. Use Best Editor For Write A Java Program Instead Of NOTEPAD You Can Use NOTEPAD++ or SUBLIME TEXT

5. If You Need Any Help Our Expert Always With You Here Your Java Expert Is Prashant Chaturvedi Sir.

Variable Declaration and Initialization


data type variable name;

variable name=value;

int empid;!

empid=112233

System.out.println(empid);

output 112233


Variable Declaration and Initialization in Java


class Program1
{
 public static void main(String[] args)
 {
 System.out.println("Program Started"); // Variable Declaration
 int empid;
 double empsalary;
 char empgrade; // Variable Initlization
 empid=123456;
 empsalary=50000.25;
 empgrade='z';

 System.out.println("Employee ID is "+empid);
 System.out.println("Employee Salary is "+empsalary);
 System.out.println("Employee ID is "+empgrade);
 System.out.println("Program Ended");
 }
}

Output:-

Variable Declaration and Initialization in Java

You May Also See


1. HOW TO PRINT DIFFERENT VALUE IN JAVA

2. Java Program To Find Area And Circumference Of Circle

3. Java Program To Print ASCII Value Of Character

4. Java Program To Find Area Of Triangle

5. Java Program to Convert a person's name in Abbreviated

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Prashant Chaturvedi

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment