Statements and operators, JAVA Programming

Assignment Help:

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


Related Discussions:- Statements and operators

How can we include images in a web page using html and java, How can we inc...

How can we include images in a web page using HTML and Java script?2011 Images in HTML It is quite straight forward to include gif and jpg images in an HTML webpage using the

What is the use of message object, Message is a light weight message having...

Message is a light weight message having only header and properties and no payload. Therefore if the If the receivers are to be notified about an event, and no data requires to be

Brute force search, how to implement brute foce in a program?

how to implement brute foce in a program?

Reading or writing disk files, For this assignment, you will simulate a fil...

For this assignment, you will simulate a file system. You will be neither creating files nor reading or writing disk files. Rather, you will have a simulation of a file system that

Compiler Design - Limit the loops, Problem : Compiler Design - Limit the lo...

Problem : Compiler Design - Limit the loops Rajni is a newbie to the programming and while learning the programming language he came to know the following rules: ???• Each

OOP, differentiate between states and behaviors of n object

differentiate between states and behaviors of n object

Write a quality and complexity analysis report, In the context of this cour...

In the context of this course work, you are asked to write a quality and complexity analysis report by applying programming design and implementation metrics for the AnagramGame Ja

Explain function arguments with the help of an example, Explain function ar...

Explain function arguments with the help of an example? Arguments on a function are comma separated list of data enclosed within braces. It describes interface among the web pa

The fancy new French restaurant La Food is very popu, The fancy new French ...

The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of the

What is the difference between SOA and a Web Service, Normal 0 ...

Normal 0 false false false EN-US X-NONE X-NONE

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd