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

Need remote synchronization tool for folders and files, Need Remote Synchro...

Need Remote Synchronization tool for folders and files? Project Description:                 We want a tool to synchronize the content of one or more folders on the file syst

Package diagrams , To simplify complex class diagrams you may group classes...

To simplify complex class diagrams you may group classes into packages.

Explain traversing through a collector using iterator, Explain traversing t...

Explain traversing through a collector using Iterator. Ans. We can access each element in Collection by using Iterators regardless of how they are organized in collector. Ite

Explain the importance of abstract classes in java, Question: (a) Expl...

Question: (a) Explain the importance of abstract classes in Java with an appropriate example. (b) Explain what is meant by an interface in Java? Use a simple example to il

Difference between stringbuffer and string class, Define the difference be...

Define the difference between StringBuffer and String class?

Develop the back end of a calculator application, For this assignment, you ...

For this assignment, you will develop the back end of a calculator application. The GUI (graphical user interface) has been provided by your instructor. The application will requir

What is meant by weaving, The process of applying aspects to a target objec...

The process of applying aspects to a target object to form a new proxy object is known as Weaving. The aspects are woven into the target object at the verified join points.

What is the importance of static variable, What is the importance of static...

What is the importance of static variable? Static variables are class level variables where all objects of the class refer to the similar variable. If one object alters the val

Banknote ocr register anti fraud, Project Description: Introduction: ...

Project Description: Introduction: SID C.A. (integradores) is a software company in Venezuela 15 years ago, and we are exploring the possibility of making mobile developments

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