Home > Default > Question about the conitional operator

Question about the conitional operator

November 30Hits:0
Advertisement
Hello! This may be a dumb question, but I still don't know the answer! =D
I know the conditional operator is an operator and not a statement, and I was reading a site http://sophia.dtp.fmph.uniba.sk/javastuff/javacourse/week2/16.html that said this works:
name.equals("Rumpelstiltskin") ? give_back_child() : laugh();
which I guess makes sense. But when I tried to compile a code just like this, it complains it's not a statement
What am I doing wrong?

Answers

Ah okay... So you always need a LHS for the conditional operator? I thought that in this case, since a function is being called, then the function is the statement. Sorta like:
if(a == b)
  doThis();
else
  doThat();So I have to store the result of a == b in c, for example, if I wanted to use the conditional operator? Even though "c" would be of no use to me whatsoever?

Read other 7 answers

Tags:

Related Articles

  • Question about the conitional operatorNovember 30

    Hello! This may be a dumb question, but I still don't know the answer! =D I know the conditional operator is an operator and not a statement, and I was reading a site http://sophia.dtp.fmph.uniba.sk/javastuff/javacourse/week2/16.html that said this w

  • Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place. TksNovember 30

    Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place

  • Question on using Distinct operator and avoiding ORA-00936 errorNovember 30

    I may have answered my own question, by searching the OTN forums, but I just want to confirm what I've learned. I'm trying to use a distinct on one of my columns, where I am pulling multiple columns, and trying to avoid duplicate entries. From most o

  • Question in floating point operationNovember 30

    Hi, I have question in java floating point operation. public class test      public static void main(String args[])           double d1 = 243.35 ;           double d2 = 2.3 ;           System.out.println(d1 * d2) ;           System.out.println((float

  • Question about EWS - The operation has timed outNovember 30

    hi everyone, I'm developing a solution which uses public folder database in Exchange Server to store tasks: - We use 1 account to access to public folder database by using EWS. - Currently, this public folder database contains 60000 tasks and they ar

  • Two questions: about volatile and operatorNovember 30

    Howdy! I need a little info on these lil' critters I've got here... First: What is the volatile modifier...? What does it do...? And second: What is the >>> or <<< operator...? First I just assumed they were bit rotation, but now I'm not

  • Questions concerning the Macintosh Operating System (very technical)November 30

    I've recently learned all about how Windows based machines do various things such as memory management, processor management, disk scheduling algorithms, concurrent/parallel processing and performance evaluation/simulation. I'm interested in learning

  • Question about not like operatorNovember 30

    HI, This where clause omitting ABC% , but I wanted to exclude some conditions I want my sql to return COLUMNA = 'ABCD' but exclude everything else 'ABC%' how do I fix this? WHERE COLUMNA NOT LIKE '%ABC' AND COLUMNA NOT LIKE 'ABC%' AND COLUMNA NOT LIK

  • Question about the new operatorNovember 30

    Hi All, Could anyone tell me if the evaluation of new-expression causes the invocation of the construtor Object() in class java.lang.object or does it just invoke the constructor of the class for which the object is being declared?? Thanks in advance

  • Question about Drag & Drop operation!November 30

    Who can give me an explaination about the methods in class DragSourceDragEvent getUserAction() getDropAction() getTargetActions() I 've read the api document , but it really conveied a unclear concept, Hope anybody can give me detaided explaination t

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.670 s.