0:07 [Music]
0:10 Welcome back to Code Chef. Imagine you
0:12 have five candies and you eat one. How
0:14 does Java know whether you had five or
0:17 four candies first? That's where
0:19 increment and decrement operators come
0:21 in. They let Java increase or decrease
0:24 values efficiently, either before or
0:26 after using them.
0:28 Think of increment and decrement like
0:30 stepping on a ladder. You can step up
0:32 before taking a photo or step up after
0:35 taking it. Similarly, Java lets you
0:37 increase or decrease a number before
0:39 using it called pre-increment or
0:42 predment or after using it called post
0:45 increment or post decrement. In Java,
0:47 the increment operator plus increases a
0:49 variable by one and the decrement
0:52 operator minus minus decreases it by
0:55 one. Pre-increment or predecment changes
0:57 the value before it's used while post
1:00 increment or post decrement changes it
1:03 after it's used. For example, if we have
1:05 Java calculates each operation as
1:09 follows. Plus plus A makes a six and
1:12 assigns six to B. A plus assigns six to
1:16 C, then increases A to 7. A decreases A
1:20 to 6 and assigns six to D. and a assigns
1:23 six to e then decreases a to five. A few
1:26 quick tips. Preverses post matters in
1:29 expressions. Increment and decrement are
1:31 useful in loops and they can be applied
1:34 to integers, floats, and array indices.
1:37 Now it's your turn. Try the beginner
1:39 friendly code chef problem called
1:41 increment and decrement practice where
1:43 you'll increase or decrease numbers in
1:46 different ways and print the results.
1:47 Today you learned that increment and
1:49 decrement operators let Java increase or
1:52 decrease values, pre-changes the value
1:55 before using it, postchanges it after
1:57 using it, and they're essential for
1:59 concise arithmetic and loops. Keep
2:02 practicing, keep coding, and remember,
2:06 code, debug, repeat. Build mastery with