0

What output results from this code?

class Person { public static int pCount; public static void main(String[ ] args) { Person.pCount = 1; Person.pCount++; System.out.println(Person.pCount); } } ------------------------ The output is 2, but i don't understand why and how!!!

2nd Mar 2021, 11:56 AM
Hanmin Park
Hanmin Park - avatar
5 Answers
+ 3
2
8th Jun 2021, 12:38 PM
Nikunj Vagadiya
Nikunj Vagadiya - avatar
+ 1
pCount is a static variable . and in line one is 1 and next line with ++ increase 2
2nd Mar 2021, 2:11 PM
Mohammad
Mohammad - avatar
+ 1
2
3rd Oct 2022, 3:15 AM
Sujit suresh shinde
0
2
3rd Oct 2022, 3:14 AM
Sujit suresh shinde
- 2
Person.pCount++ makes the variable increased by 1.
2nd Mar 2021, 12:06 PM
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż
äœ çŸ„é“èŠć‰‡ïŒŒæˆ‘äčŸæ˜Ż - avatar