operatorfunctionalityexampleexplanationsets one


Operator

Functionality

Example/Explanation

=

Sets one value equal to another

counter=0  Sets the counter to equivalent the number 0

+=

Shortcut for adding to the current value.

clicks += 2  Sets the variable named counter to equivalent the current value plus two.

-=

Shortcut for subtracting from the current value.

clicks -= 2  Sets the variable named counter to equivalent the current value minus two.

*=

Shortcut for multiplying the current value.

clicks *= 2  Sets the variable named counter to equivalent the current value multiplied by two.

/=

Shortcut for dividing the current value.

clicks /= 2  Sets the variable named counter to equivalent the current value divided by two.

Description: The comparison operators used to compare two items & return a value of "true"if the condition evaluates to true, else they return false.

Functionality

Example/Explanation

==

Returns a true value if the items are the similar

Counter == 10  Returns the value "true" if the counter's value is equal to the number 10 currently

!=

Returns a true value if the items are not the similar

Counter != 10  Returns the value "true" if the counter's value is any value apart from the number 10

Returns a true value if the item of left is greater than the item of right

counter>10  Returns the value "true" if the counter's value is larger than the number 10

>=

Returns a true value if the item of left is equal to or greater than the item of right

counter>=10  Returns the value "true" if the counter's value is equivalent to or larger than the number 10

Returns a true value if the item of left is less than the item on the right

counter<10  Returns the value "true" if the counter's value is smaller than the number 10

<=

Returns a true value if the item of left is equal to or less than the item of right

counter<=10  Returns the value "true" if the counter's value is equivalent to or less than the number 10

Computational Operators

Description: The computational operators carry out a mathematical function on a value or values, and return a single value.

       operation

 Functionality

Example/Explanation

+

Adds two values together

counter+2  Returns the sum of the counter plus 2

-

Subtracts one value from another

counter-2  Returns the sum of the counter minus

2

*

Multiplies two values

counter*10  Returns the result of variable times 10

/

Divides the value of left by the one on the right and the result returns

counter/2  Divides the current value of the counter through 2 and returns the result

++X

Increments the value, & then returns the result

++counter  Looks at the current value of the counter, increments it through one, and then returns the result. If the counter contains a value of 3, this expression returns the value of 4.

X++

Returns the value, & then increments the value

counter++ Returns the value of the counter, then  do increments in the counter. If the counter contains a value of 3, this expression returns the value of 3, and then sets the counter value to 4.

--X

Decreases the value, & then returns the result

--counter Looks at the current value of the counter, decreases it through one, and then returns the result. If the counter contain a value of 7, this expression returns the value of 6.

X--

Returns the value, and then decreases the value

counter--  Returns the value of the counter, then decreases the counter value. If the counter contains a value of seven, this expression returns the value of seven, then sets the counter value to six

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: operatorfunctionalityexampleexplanationsets one
Reference No:- TGS0266435

Expected delivery within 24 Hours