Difference between a++; and a = a + 1; statements in Java

Publicado el: 13 noviembre 2018
en el canal de: VK Programming Villa
2,233
40

In this tutorial we’re going to look at very important Java concept difference between a++; and a = a + 1; statements according to the SCJP/OCJP Exam as well as technical interview point of view and learn it with small small examples in detail.

In this tutorial, we will learn about a = a + 1; statement in example 2 in which this statement will generates compile time error saying, error: incompatible types: possible lossy conversion from int to byte.
The Reason behind is If we apply any arithmetic operator ( +,-, *, /, %) between two byte type, short type or int type variables a and b, the return type is always max( int, type of a, type of b).

In Example 3, we learn about a++; statement which is postfix increment statement and in this case, error will not occur, because the reason behind is, in the case of increment and decrement operator, internal type casting will be performed automatically.

#java #incrementOperator #incompatibleTypes #a++ #a=a+1 #SCJP #OCJP #Interview #Programming #Tutorials

Social Links: Don't hesitate to contact me if you have any further questions.

FACEBOOK:   / cse.programming.assignments  

GOOGLE+ :
https://plus.google.com/u/0/114693282...

Quora: https://www.quora.com/profile/Vinay-K...

Related Videos:    • OCJP-SCJP Exam / Java Interview Preparation  

Gmail: vkprogrammingvilla.com


En esta página del sitio puede ver el video en línea Difference between a++; and a = a + 1; statements in Java de Duración hora minuto segunda en buena calidad , que subió el usuario VK Programming Villa 13 noviembre 2018, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 2,233 veces y le gustó 40 a los espectadores. Disfruta viendo!