I have declared member variables of a class in 2 separate way:
Class MyClass
{
int x,y;
}
Class YourClass
{
int x;
int y;
}
What is the difference between these two declaration?
I have declared member variables of a class in 2 separate way:
Class MyClass
{
int x,y;
}
Class YourClass
{
int x;
int y;
}
What is the difference between these two declaration?
There is no difference between two approach.
First approach data type is common for all of its variable.
For readability second approach look nice.
There isn't any difference technically.
But it is choice of programmer to declare as how he/she feels is comfortable to read. Second choice would be more readable when you have numerous fields (POJOs) where could easily get lost reading the elements :)