IntelliJ Java IDE
The moose likes Ranch Office and the fly likes Unary operators Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Practical Unit Testing with TestNG and Mockito this week in the Testing forum!
JavaRanch » Java Forums » This Site » Ranch Office
Reply Bookmark "Unary operators" Watch "Unary operators" New topic
Author

Unary operators

dhruv simaria
Greenhorn

Joined: Mar 26, 2001
Posts: 6
well Simon Roberts in his book has mentioned, that for Unary operators ,2 rules aply. One of them being that if the operand is byte,short or a char,it is converted to an int.
Using this rule
When you run this code ,the ouput should be type mismatch, as we can't convert int value to char type without casting,but surprisingly when you run this code you get the answer as - The value is b
Why?

[This message has been edited by dhruv simaria (edited March 26, 2001).]
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18652
Hi, welcome to JavaRanch. This particular forum is intended for discussion about JavaRanch itself, not for questions about the Java language. I am moving this post to Java in General (Beginner), which is a good place for your questions about the language.


"I'm not back." - Bill Harding, Twister
 
IntelliJ Java IDE
 
subject: Unary operators
 
Threads others viewed
assignment operator
Unary operators
Arithmetic promotion
Automatic conversion of the byte, short and char
Arithmetic promotion
developer file tools