what is this means int a+=1 in java

Recommended Answers

that should mean:

int a = a + 1;

but it should be also an error if you try to add 1 to uninitialized a if a is local variable of a method
however if a is a class variable than it is initialized by default to 0 so this …

Jump to Post

All 2 Replies

It means int a = a + 1;

Member Avatar

that should mean:

int a = a + 1;

but it should be also an error if you try to add 1 to uninitialized a if a is local variable of a method
however if a is a class variable than it is initialized by default to 0 so this code would make it 1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.