filmov
tv
Increment and Decrement Operator in Java Part 1 - Java Tutorial 21
Показать описание
Notes for You:: Increment and Decrement Operator in Java Part 1 - Java Tutorial 21
Increment and Decrement Operators:
- are used to increment or decrement a variable value by 1.
Increment Operator (++):
- is used to increment a variable value by 1.
Post Increment : variableName ++
Pre Increment : ++ variableName
Decrement Operator (--):
- is used to decrement a variable value by 1.
Post Decrement: variableName --
Pre Decrement : -- variableName
Note:
- If we use increment or decrement operator as an independent statement then we don’t find any difference in the output.
- where as If we use an increment or decrement operator as part of an expression or a function call then we find the difference in the output.
Example code1:
package incrementdecrementoperatorsdemo;
public class IncrementDecrementOperatorsDemo
{
public static void main(String[] args)
{
/*
int a = 10;
a++; // a=a; a=a+1;
int a = 10;
++a; // a=a+1; a=a;
int a = 10;
a--; // a=a; a=a-1;
*/
int a = 10;
--a; // a=a-1; a=a;
}
}
=========================================
Follow the link for next video:
Follow the link for previous video:
=========================================
Java Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
C++ Tutorials Playlist:
C# Tutorials Playlist:-
C Programming Tutorials Playlist:
C Practical LAB Exercises Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JAVA #JAVATutorial
Increment and Decrement Operators:
- are used to increment or decrement a variable value by 1.
Increment Operator (++):
- is used to increment a variable value by 1.
Post Increment : variableName ++
Pre Increment : ++ variableName
Decrement Operator (--):
- is used to decrement a variable value by 1.
Post Decrement: variableName --
Pre Decrement : -- variableName
Note:
- If we use increment or decrement operator as an independent statement then we don’t find any difference in the output.
- where as If we use an increment or decrement operator as part of an expression or a function call then we find the difference in the output.
Example code1:
package incrementdecrementoperatorsdemo;
public class IncrementDecrementOperatorsDemo
{
public static void main(String[] args)
{
/*
int a = 10;
a++; // a=a; a=a+1;
int a = 10;
++a; // a=a+1; a=a;
int a = 10;
a--; // a=a; a=a-1;
*/
int a = 10;
--a; // a=a-1; a=a;
}
}
=========================================
Follow the link for next video:
Follow the link for previous video:
=========================================
Java Tutorials Playlist:-
=========================================
Watch My Other Useful Tutorials:-
C++ Tutorials Playlist:
C# Tutorials Playlist:-
C Programming Tutorials Playlist:
C Practical LAB Exercises Playlist:-
=========================================
► Subscribe to our YouTube channel:
► Visit our Website:
=========================================
Hash Tags:-
#ChidresTechTutorials #JAVA #JAVATutorial
Комментарии