I just started my journey to learn how to build mobile apps with @ingressive4Good and @thezuriteam who are providing free software development and design trainings to young people all over Africa. I joined the Kotlin (Java) track and have been leveraging SoloLearn for Java lessons and Replit to practice.
On getting to Operators on SoloLearn, I found prefix and postfix operators a little confusing. The difference between what happens when the operator is before and after the operand seemed a bit strange. So I practiced a bit on my Replit scratchpad and arrived at a way to correctly interpret their actions:
- prefix: take action (increment or decrement) on operand first before doing any other thing.
- postfix: take action on operand after doing every other thing.
The interesting part of this story is that I tried to see if I was the only one who found this challenging. I posted a poll with a simple problem and was both surprised and relieved by the result. Even though only a few person voted, they all got the answer wrong!
Etekah Enameti @etekahe
What is the output of this code snippet?int n = 64;
System.out.println(n++);#Java
#100DaysOfCode 18:47 PM – 01 Apr 2021
Do you really know how prefix and postfix operators work? Think again!
暂无评论内容