public class Demo {
public static void main(String[] args) throws {
int positiveVal = 100;
int negativeVal = (~(positiveVal - 1));
("Result: Positive value converted to Negative = "+negativeVal);
positiveVal = ~(negativeVal - 1);
("Actual Positive Value = "+positiveVal);
negativeVal = -200;
("Actual Negative Value = "+negativeVal);
positiveVal = ~(negativeVal - 1);
("Result: Negative value converted to Positive = "+positiveVal);
}
}