When I execute the code in c# and java, I get different output.
In c#, got the output 254
but in java got the output -2
. Why does it behave differently in term of output? But I want the same output in java means I want output 254
.
In c# code:
static void Main(string[] args)
{
byte value = 1;
System.Console.WriteLine("Value after conversion {0}", (byte)(~value));
}
Output : 254
In Java code:
public static void main(String[] args) {
byte value = 1;
System.out.println((byte)(~value ));
}
Output : -2