What are different ways of creating variable in Java.

937    Asked by RaghavSingh in QA Testing , Asked on Dec 28, 2019
Answered by Raghav Singh

There are 3 different ways of creating variables in Java.

Declare variable in one line and Define in another

DataType VariableName;

VariableName = Value;


Declare and Define variable in the same line

DataType VariableName = Value;


For declaring multiple Variables;

DataType VariableName1, DataType VariableName2, DataType VariableName3;

VariableName1 =value1;

VariableName2= value2;

VariableName3 = value3



Your Answer

Interviews

Parent Categories