Q:

Variable Declaration and Initialization in Java

0

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
 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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:

Program Started

Employee ID is 123456

Employee Salary is 50000.25

Employee ID is z

Program Ended

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

How to Concatenation in Java Using + Operator... >>
<< How To Print Message \" HELLO JAVA \" In...