English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

temp = temp - (temp > 150 ? 100 : 20 ) ;

Is there somewhere online I can get a complete list of operators?

2007-05-14 08:06:32 · 5 answers · asked by Anonymous in Computers & Internet Programming & Design

5 answers

Somewhere online where you can get a list...Well, normally I just use Google or a search engine to find stuff. I'm guessing Google doesn't work for you? Because look at the first two results for http://www.google.com/search?q=java+operators

? is a ternary operator. temp > 150 returns either true or false. If true, the ternary operator returns 100, otherwise 20.

Effectively, you get
if temp > 150:
temp = temp - 100
else:
temp = temp - 20

2007-05-14 08:13:02 · answer #1 · answered by csanon 6 · 2 0

(temp > 150 ? 100 : 20 )
means
if temp > 150 then result=100 else result=20



temp = temp - (temp > 150 ? 100 : 20 )
means
temp =temp-result

2007-05-14 08:16:00 · answer #2 · answered by iyiogrenci 6 · 0 1

The ternary operator is inherited from the C programming language. The value of

a ? b : c

is b if a is nonzero and c if a is zero. So your statement means if temp is greater than 150, subtract 100 from it, else subtract 20 from it.

2007-05-14 08:14:21 · answer #3 · answered by Anonymous · 0 1

here is a good site for operator terminology
http://www.cafeaulait.org/course/week2/03.html

http://java.about.com/od/beginningjava/l/aa_operator_1.htm

the statement (temp > 150 ? 100 : 20 )
is equivalant to:

if temp > 150 then
temp=temp-100
else
temp=temp-20
end if

2007-05-14 08:16:41 · answer #4 · answered by math guy 2 · 0 0

A full list of operators can be found here

2007-05-14 08:20:07 · answer #5 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers