4.5 Post and Pre Increment in Java

The increment operator increases the value of the variable by one .
these operators have two forms each: prefix and postfix. In prefix form, the operand appears before the operand while in post fix form, the operand appears after the operand.
Check out our website: www.telusko.com
Follow Telusko on Twitter: / navinreddy20
Follow on Facebook:
Telusko : / teluskolearnings
Navin Reddy : / navintelusko
Follow Navin Reddy on Instagram: / navinreddy20
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi
Subscribe to the channel and learn Programming in easy way.
Java Tutorial for Beginners: goo.gl/p10QfB
C Tutorial Playlist : goo.gl/8v92pu
Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
XML Tutorial : goo.gl/Eo79do
Design Patterns in Java : goo.gl/Kd2MWE
Socket Programming in Java : goo.gl/jlMEbg
Spring MVC Tutorial : goo.gl/9ubbG2
OpenShift Tutorial for Beginners : goo.gl/s58BQH
Spring Framework with Maven : goo.gl/MaEluO
Sql Tutorial for Beginners : goo.gl/x3PrTg
String Handling in Java : goo.gl/zUdPwa
Array in Java : goo.gl/uXTaUy
Java Servlet : goo.gl/R5nHp8
Exception Handling in Java : goo.gl/N4NbAW

Пікірлер: 85

  • @snehajaiswal5778
    @snehajaiswal57786 жыл бұрын

    Increment confused me always! Thank you for this wonderful explanation :)

  • @kesikajeevathayaparan4157
    @kesikajeevathayaparan41574 жыл бұрын

    A very clear explanation I found. Thank you so much. Really appreciate your work.

  • @mohit6258
    @mohit62585 жыл бұрын

    Initially I thought of disliking this video. But when i put my brain into it, I found I was doing it all wrong before. This video clears the real concept how increment and decrement operator works. Thanks

  • @praveermadhupushpa6518

    @praveermadhupushpa6518

    4 жыл бұрын

    try debugging and then execute bro

  • @madhavanand756
    @madhavanand7566 жыл бұрын

    The only best tutor for computer on KZread 😎

  • @appleberry2935
    @appleberry29355 жыл бұрын

    Thanks for explaining a short and understandable concept that even some technical books fail to.

  • @inderpreetsingh1995
    @inderpreetsingh19955 жыл бұрын

    Thank uh sir ...! You made it easy for us itzz just a small concept but confusing also

  • @saishmhatrearts
    @saishmhatrearts7 жыл бұрын

    sir i watched today ur oop playlist its awesome....!!!!

  • @faizansadique5769
    @faizansadique57694 жыл бұрын

    I was so much lucky that I got your channel first on my question difference between I++ & ++I you explained it so well or I should say you just spoonfeeded us thanks a lot love from Kolkata

  • @marvhartigan3677

    @marvhartigan3677

    3 жыл бұрын

    hehe

  • @saishmhatrearts
    @saishmhatrearts7 жыл бұрын

    now i head up with this playlist witch contains 174 video for biginners...thank you...!!!

  • @nilesh122n
    @nilesh122n8 жыл бұрын

    very good,really helpful for me.

  • @zeyadjy7229
    @zeyadjy72294 жыл бұрын

    so this is why in a for loop the i++ will affect the loop counter after the first execution of the loop?

  • @saadafm
    @saadafm4 жыл бұрын

    Thanks! Great explanation

  • @shirsho22
    @shirsho226 жыл бұрын

    Quite helpful !

  • @SmartProgramming
    @SmartProgramming6 жыл бұрын

    nice explanation sir, it easy to learn java from you, thanks 👍👍

  • @parasarora2606
    @parasarora26068 жыл бұрын

    sir ,this mean that assignment operator having high priority over post increment and pre increment

  • @akhilsuresh9536
    @akhilsuresh95367 жыл бұрын

    Sir, is this an exception? In all other cases, the value of increments gets reflected from the next line itself!!!

  • @vineethsaivarada1961
    @vineethsaivarada19616 жыл бұрын

    Hi Navin... What is the scenario for i = ++i The answer will be 1 incremented to the current value... Can you please provide the internal explaination of it, as done in the video.

  • @user-wg6ud3hh1n
    @user-wg6ud3hh1n7 ай бұрын

    CLear explanation.thank you

  • @hearttouchingmotivation6603
    @hearttouchingmotivation66033 жыл бұрын

    Awesome work

  • @-indeed8285
    @-indeed82856 жыл бұрын

    amazing videos

  • @chagantisrichandana8422
    @chagantisrichandana84224 жыл бұрын

    Thank u Reddy sir

  • @girlstjohnian
    @girlstjohnian2 жыл бұрын

    Thank you so muchhhhh sir!!

  • @NarendraKolink
    @NarendraKolink8 жыл бұрын

    Thanks..a lot...

  • @shuvshaw9594
    @shuvshaw95944 жыл бұрын

    Very helpful

  • @mithileshchandra2072
    @mithileshchandra20722 жыл бұрын

    Awesome 👍

  • @sivapradeep977
    @sivapradeep9773 жыл бұрын

    Is it same for all versions sir.....???

  • @ikramasharfi5047
    @ikramasharfi50477 жыл бұрын

    sir pls add some java questions of output printing, i m very poor in that

  • @gobinathg5101
    @gobinathg51016 жыл бұрын

    Great!

  • @drakshayanibakka11
    @drakshayanibakka114 жыл бұрын

    hello consider this snippet a=5; b=( --a + a-- ) and when i print b it shows 8 in java and 7 in C both languages showing different outputs . why such difference ? pls help me out

  • @aniruddhamukherjee5099
    @aniruddhamukherjee50992 жыл бұрын

    thanks for the video

  • @kiranthakur5743
    @kiranthakur57434 жыл бұрын

    Can we increase more than 1 number by using post and pre increment

  • @JeevanJeevDb
    @JeevanJeevDb3 жыл бұрын

    Really cool

  • @Fosten12
    @Fosten128 ай бұрын

    i finally understood it

  • @S2KEVIN
    @S2KEVIN3 жыл бұрын

    bravo sir

  • @Mrtargetlocked
    @Mrtargetlocked4 жыл бұрын

    Thankyou

  • @vidhyapriyadharsini234
    @vidhyapriyadharsini2345 жыл бұрын

    Thanks

  • @reiland3871
    @reiland38713 жыл бұрын

    Thank you for the uploading and explaining this very clearly however can someone explain how I getting the following results please? Thank you n = 5; System.out.println(n-- - --n); // result is n = 2 x = 5; System.out.println(x++ - --x); // result is x = 0

  • @lokeshmotwani6121
    @lokeshmotwani61215 жыл бұрын

    Thanku sir

  • @nightshadow591
    @nightshadow591 Жыл бұрын

    Tysm 👍

  • @friedchicken5227
    @friedchicken52273 жыл бұрын

    👍 thanks

  • @teengod1520
    @teengod15202 жыл бұрын

    Arigato!! 💜

  • @Namakarana
    @Namakarana4 жыл бұрын

    If temp=i what will be the output

  • @NarendraKolink
    @NarendraKolink8 жыл бұрын

    Does this same thing happened in c++ ?? Just like java. does c++ also use temp variable while i = i++ ??

  • @varunaggarwal1995

    @varunaggarwal1995

    7 жыл бұрын

    Collections and Generics

  • @venkatgadamsetty3584

    @venkatgadamsetty3584

    7 жыл бұрын

    Telusko Learnings wo w

  • @venkatgadamsetty3584

    @venkatgadamsetty3584

    7 жыл бұрын

    How can i write outpits for programs easily

  • @venkatgadamsetty3584

    @venkatgadamsetty3584

    7 жыл бұрын

    Pls give me the reply i have much time

  • @venkatgadamsetty3584

    @venkatgadamsetty3584

    7 жыл бұрын

    Or show me the video

  • @aniruddwakikar3004
    @aniruddwakikar30044 жыл бұрын

    Is it good to learn java 8 in 2020

  • @justfeelmusic162
    @justfeelmusic1623 жыл бұрын

    Can you explain when j : i , How it comes i=6

  • @onlineworld3838
    @onlineworld38382 жыл бұрын

    Thank you sir form omprakash

  • @sahilchauhang
    @sahilchauhang8 жыл бұрын

    sir please ans this____ public class PrePost { public static void main(String[] args) { int i = 5; i = i++; System.out.println(i); i = ++i; System.out.println(i); int j = i++; System.out.println(j); int k = ++i; System.out.println(k); } } according to me ans is 5 6 6 7 but when i run this code netbeans it shows: 5 6 6 8 how this is possible?

  • @avvahfarhana8395

    @avvahfarhana8395

    7 жыл бұрын

    first: i = i++; as its explained in the video its same as int temp; temp = i; i++; i= temp; so the output will be 5. second: i = ++i; It is a pre Increment. so output will be 6. third: j = i++; the value of i has become 6 from second operation. it assigns 6 to j and then increments i to 6+1 = 7, because i++ is post increment so the value of j=6 and i=7 since you are printing j, output will be 6 fourth: k=++i; here i is pre incremented. the value of i will be 7 from third step, since its a pre increment its first increments the value of i to 8 (7+1), and then assigns it to k. So the output og k=8.

  • @sahilchauhang

    @sahilchauhang

    7 жыл бұрын

    Thanks

  • @akashjadhav8345

    @akashjadhav8345

    6 жыл бұрын

    Avvah Can you Please help me also... Dear Avvah, Please clear my doubts on Increment/Decrement Operators in JAVA..., Please Observed This code Below.. class Test { public static void main(String[] args) { int a = 10 ; // line 1 a = ++a ; // line 2 a = a++ ; // line 3 System.out.println(a); // line 4 } } Output ::: ---> 11 it is right And Sir, Please observed the following variations also::: Sir, if I am replace //line 3 with this following Expressions so it shows Unexpected Output Sir.. 1) a = a++ + a++ ; replace Line 3 with This Expression Output is :::--> 23 // But, why I am getting 23... instead of 22..... 2) a = a++ + a++ + a++ ; replace Line 3 with This Expression Output is :::--> 36 // I think it is true but,,see below Expression 3) a = a++ + a++ + a++ + a++ ; replace Line 3 with This Expression Output is :::--> 50 // But, why I am getting 50...instead of 48 4) a = a++ + a++ + a++ + a++ + a++; replace Line 3 with This Expression Output is :::--> 65 // But, why I am getting 65... instead of 60 Sir, Please Please Please clear my doubts as early as posiible.....I am very tensed about it ....

  • @ravikaushish
    @ravikaushish7 жыл бұрын

    did anyone else notice that? In the last video they were working on a windows platform but in this video, they are using a MacBook...congrats sir

  • @venkateswarluguntaka7370
    @venkateswarluguntaka73704 жыл бұрын

  • @CodeThrill
    @CodeThrill5 жыл бұрын

    Luv

  • @lokeshmotwani6121
    @lokeshmotwani61215 жыл бұрын

    Can you tell this a=6 ,b=3 +a-- +10

  • @krishna_rohith244

    @krishna_rohith244

    4 жыл бұрын

    15

  • @Rohan-rd8ru
    @Rohan-rd8ru3 жыл бұрын

    6:20 you printed i instead of temp

  • @shantikallagunta6917
    @shantikallagunta69175 жыл бұрын

    All the operations are not shown properly.. Can you clearly keep a video..

  • @pranathipalli2086
    @pranathipalli20864 жыл бұрын

    i=++i gives 6 please explain it

  • @thewatcher8657

    @thewatcher8657

    2 жыл бұрын

    Because pre increment works that way

  • @rishiganeshbandaru9812
    @rishiganeshbandaru9812 Жыл бұрын

    are u telugu sir??

  • @asnakeseyoum3109
    @asnakeseyoum31092 жыл бұрын

    who is watching this video after seeing in the question that is asked?

  • @aniruddwakikar3004
    @aniruddwakikar30044 жыл бұрын

    Pls reply sir

  • @unknownunknown8699
    @unknownunknown86992 жыл бұрын

    6:50 not cool confusing.

  • @-TEST-0
    @-TEST-03 ай бұрын

    i will never understand....

  • @theengineer8301
    @theengineer83016 жыл бұрын

    Not at all helpful. The guy is himself in doubt. Tremendously confusing explanation.

  • @shivangianand6341
    @shivangianand63416 жыл бұрын

    worse explanation really here u r still confused

  • @akashjadhav8345

    @akashjadhav8345

    6 жыл бұрын

    very Helpful Video... Are you serious... worse explanation really here u r still confused

  • @adityasankarsadhukhan6389
    @adityasankarsadhukhan63896 жыл бұрын

    worst explanation i ever saw

  • @akashjadhav8345

    @akashjadhav8345

    6 жыл бұрын

    Very nice Teaching Skills

  • @yaoyaoxiong2371

    @yaoyaoxiong2371

    4 жыл бұрын

    bro thats mean