Home /
Expert Answers /
Computer Science /
using-shortcut-operators-in-java-below-4-data-values-are-given-to-you-write-a-program-to-add-s-pa231
(Solved): Using shortcut operators in java Below 4 data values are given to you. Write a program to add/s ...
• Using shortcut operators in java Below 4 data values are given to you. Write a program to add/subtract from the numbers as noted in the comment and display the values to the console. int a 10; // add 1 to 'a' using shortcut operator and display (print to console) int b = 5; // subtract 1 from 'b' using shortcut operator and display int c = 15; //add 5 to 'c' using shortcut operator and display int d = 20; //subtract 5 from 'd' using shortcut operator and display
JAVA Shortcut Operators: (1) += Operator To add a to x we can use x+=a it is a way of representing x=x+a Note: If we just want to add 1 to a we can also represent it in the form a++ i.e. incrementing a by 1 or a=a+1 or a+=1 (2) -= Operator To subtrac