

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between x++ and x= x+1 in Java programming
x++ automatically handles the type casting where as x= x + 1 needs typecasting in case of x is not an int variable. See the example below.
Example
public class Tester { public static void main(String args[]) { byte b = 2; //Type casting is required //as 1 is int and b is byte variable b = (byte) (b + 1); System.out.println(b); byte b1 = 2; //Implcit type casting by the compiler b1++; System.out.println(b1); } }
Output
3 3
- Related Questions & Answers
- Difference between x++ and x = x+1 in Java
- Difference between NumberLong(x) and NumberLong(“x”) in MongoDB?
- Sum of the Series 1 + x/1 + x^2/2 + x^3/3 + .. + x^n/n in C++
- Absolute difference between the first X and last X Digits of N?
- Count Elements x and x+1 Present in List in Python
- Python Program to Generate a Dictionary that Contains Numbers (between 1 and n) in the Form (x,x*x).
- Differences between Python 2.x and Python 3.x?
- Difference between %p and %x in C/C++
- Program to find sum of 1 + x/2! + x^2/3! +…+x^n/(n+1)! in C++
- Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors in C++
- Find x, y, z that satisfy 2/n = 1/x + 1/y + 1/z in C++
- Important differences between Python 2.x and Python 3.x with examples
- Construct a frequency array of digits of the values obtained from x^1, x^2, ....., x^n in C++
- Difference between application/x-javascript and text/javascript content types?
- What are the key differences between Python 2.7.x and Python 3.x?
Advertisements