A char
can be assigned to an int
without a cast because that is a widening conversion. To do the reverse, an int
to a char
requires a cast because it is a narrowing conversion.
More Related Contents:
- In Java, is the result of the addition of two chars an int or a char?
- Java: parse int value from a char
- Convert int to char in java
- Java – char, int conversions
- How does subtracting the character ‘0’ from a char change it into an int?
- negative char Value JAVA
- How can I convert a char to int in Java? [duplicate]
- Adding char and int
- Why is char[] preferred over String for passwords?
- Determine if a String is an Integer in Java [duplicate]
- Why is 08 not a valid integer literal in Java?
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- What is the difference between Integer and int in Java?
- Java Array Sort descending?
- Check string for palindrome
- How to convert a char array back to a string?
- How can non-ASCII characters be removed from a string?
- Putting char into a java string for each N characters
- Fastest way to iterate over all the chars in a String
- Convert boolean to int in Java
- Java int to String – Integer.toString(i) vs new Integer(i).toString()
- The concatenation of chars to form a string gives different results
- What does an integer that has zero in front of it mean and how can I print it?
- Splitting String and put it on int array
- What is the best way to tell if a character is a letter or number in Java without using regexes?
- How do I apply the for-each loop to every character in a String?
- Why is Java able to store 0xff000000 as an int?
- Integer division in Java [duplicate]
- Using int vs Integer
- Converting an int array to a String array