Short Circuit AND question (code included)

I have a quick question about the short circuit AND operator...
public class prac1 {
     public static final int aNumber = 19;
     public int age = 53;
     public static void main(String args[]) {
          if ((aNumber == 18) && (aNumber != 10)) {
               System.out.println("You got it!");
}You see I learned that Short Circuit AND means the first expression is evaluated and if it's false the 'code' is executed...
So here is what I am understanding: if((aNumber == 18) already evaluates to false, right, but then I see it as && sees that it's false, but then shouldn't the code execute?
Most likely the case: if((aNumber == 18) already evaluates to false, and because && only evaluates false expressions, and therefore since it's false the code doesn't execute... Am I correct?
Just trying to get the && and || down... Thanks!
Edited by: JavaPWNZ on Jul 2, 2008 5:58 AM

sc3sc3 wrote:
PhHein wrote:
Hi,
a bit confusing, but sort of yes. The && evaluates the first part ((aNumber == 18)) if that is false the following condition is not evaluated any more bacause the whole statement is false.
Try this: String s = null;
if(s != null && s.length() > 0){
System.out.println("Here");
}now try:
String s = null;
if(s != null & s.length() > 0){
System.out.println("Here");
nullpointer :-)As intended :)

Similar Messages

  • Object Code Short Text,Cause Code Short text and Problem Code Short Text..?

    Dear All,
    can any one help me in finding of Object Part Code Short text,Problem Code short text and Cause code short text fields....in which table it will be storing/function module to get this...?
    Thankx in Advance....

    hi,
    you want for which object??
    all the short text stored in the text table like
    T001t ( it starts with T and ends with T )
    cheers,
    sasi

  • NWDI Short Overvie and Questions

    Hello!
    Can someone explain me the steps when you work with the SAP NWDI?
    I have been surfing in the internet for 3 days and collected some information about the NWDI.
    But there are still some questions, I couldn't answer myself.
    1) Can you explain me, what a "Track" is? Please give me an example for better understanding.
    2) Can you explain me the steps, when you start a new projekt in the NWDI? I don't want to know, where you have to click in the GUI of the NWDS, but I want to know, what exactly happens in the CBS, DTR, CMS and so on....
    3) What is the SLD? I found out, that there everything is administrated?
    4) What is the diferent between a track and a product?
    It would be very nice, if you could answer some of my questions or give me a Link (favored in German) where I can read by myself.

    Hi,
    Steps are below :
    1. Please ask the BASIS team for below details once NWDI is installed.
    a) Message Server host and port of J2ee engine and  SLD url
    Once you will get this information then open your NWDS and put the above information in following way
    a) Windows>Preferences and click on SAP J2ee Engine from left menu and select radio button "SAP J2ee Engine is installed on remote host" and put message server host and port number
    b) Windows>Preferences and expand Java Development infrastructure > Development Config and put the NWDI url .
    Your developer studio is ready to work with NWDI .
    Please refer this [NWDI Link|http://wiki.sdn.sap.com/wiki/display/JDI/NWDIRelatedNotesandLinks] and [Components Development with the NWDI|http://help.sap.com/saphelp_nw72/helpdata/en/49/2fe24eb7476b1fe10000000a42189d/content.htm] and
    [Reg Track Information|http://help.sap.com/saphelp_nw72/helpdata/en/73/cf61253f4c4536b5047faf6e9e7f71/content.htm]
    Hope this helps!!
    Thanks & Regards
    Vijay
    Edited by: VijaySAPEP on Sep 8, 2011 11:45 AM

  • Short-circuiting boolean expressions

    There is a term used in other languages to describe the behavior of compiled code which evaluates boolean expressions: short circuiting. Basically, it means that if a term in an expression determines its value, then following terms never get evaluated, since they are irrelevant. For example, I have noticed that this always works in AppleScript:
    if class of x is not integer or x > 32 then . . . .
    But this will throw an exception if x is something that can’t be coerced into a number:
    if x > 32 or class of x is not integer then . . . .
    It looks to me that the reason the first always works is that Applescript is short-circuiting, and therefore there is no attempt to evaluate the inequality if x is of inappropriate class.
    Does anyone know if Applescript’s behavior is sufficiently well defined that I can be confident it will always short circuit? I know I can avoid the issue by breaking such expressions into separate, nested, if statements. If there is no such assurance that is what I will probably make a habit of doing. But I thought I'd ask if this is really necessary.

    Hello
    Short-circuiting is well-defined in AppleScript.
    cf. ASLG > Operator References (p.179 of ASLG pdf)
    http://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/Appl eScriptLangGuide/AppleScriptLanguageGuide.pdf
    Regards,
    H

  • IMac to tv with hdmi short circuit

    I have my iMac (Intel) connected to my Sony tv with an hdmi adapter.  It works fine except that sometimes the iMac seems to short circuit and turn off.  I read once that my cable may not be appropriate but then I lost that info.  Can anyone help?

    For the "Arangements" option to appear, the external display must be turned on with the correct input selected and connected to the computer.  Then close system prefs, reopen, go to "Display" and "Arrangement" will be along the top. 

  • Pl/sql boolean expression short circuit behavior and the 10g optimizer

    Oracle documents that a PL/SQL IF condition such as
    IF p OR q
    will always short circuit if p is TRUE. The documents confirm that this is also true for CASE and for COALESCE and DECODE (although DECODE is not available in PL/SQL).
    Charles Wetherell, in his paper "Freedom, Order and PL/SQL Optimization," (available on OTN) says that "For most operators, operands may be evaluated in any order. There are some operators (OR, AND, IN, CASE, and so on) which enforce some order of evaluation on their operands."
    My questions:
    (1) In his list of "operators that enforce some order of evaluation," what does "and so on" include?
    (2) Is short circuit evaluation ALWAYS used with Boolean expressions in PL/SQL, even when they the expression is outside one of these statements? For example:
    boolvariable := p OR q;
    Or:
    CALL foo(p or q);

    This is a very interesting paper. To attempt to answer your questions:-
    1) I suppose BETWEEN would be included in the "and so on" list.
    2) I've tried to come up with a reasonably simple means of investigating this below. What I'm attempting to do it to run a series of evaluations and record everything that is evaluated. To do this, I have a simple package (PKG) that has two functions (F1 and F2), both returning a constant (0 and 1, respectively). These functions are "naughty" in that they write the fact they have been called to a table (T). First the simple code.
    SQL> CREATE TABLE t( c1 VARCHAR2(30), c2 VARCHAR2(30) );
    Table created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE pkg AS
      2     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER;
      3     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER;
      4  END pkg;
      5  /
    Package created.
    SQL>
    SQL> CREATE OR REPLACE PACKAGE BODY pkg AS
      2 
      3     PROCEDURE ins( p1 IN VARCHAR2, p2 IN VARCHAR2 ) IS
      4        PRAGMA autonomous_transaction;
      5     BEGIN
      6        INSERT INTO t( c1, c2 ) VALUES( p1, p2 );
      7        COMMIT;
      8     END ins;
      9 
    10     FUNCTION f1( p IN VARCHAR2 ) RETURN NUMBER IS
    11     BEGIN
    12        ins( p, 'F1' );
    13        RETURN 0;
    14     END f1;
    15 
    16     FUNCTION f2( p IN VARCHAR2 ) RETURN NUMBER IS
    17     BEGIN
    18        ins( p, 'F2' );
    19        RETURN 1;
    20     END f2;
    21 
    22  END pkg;
    23  /
    Package body created.Now to demonstrate how CASE and COALESCE short-circuits further evaluations whereas NVL doesn't, we can run a simple SQL statement and look at what we recorded in T after.
    SQL> SELECT SUM(
      2           CASE
      3              WHEN pkg.f1('CASE') = 0
      4              OR   pkg.f2('CASE') = 1
      5              THEN 0
      6              ELSE 1
      7           END
      8           ) AS just_a_number_1
      9  ,      SUM(
    10           NVL( pkg.f1('NVL'), pkg.f2('NVL') )
    11           ) AS just_a_number_2
    12  ,      SUM(
    13           COALESCE(
    14             pkg.f1('COALESCE'),
    15             pkg.f2('COALESCE'))
    16           ) AS just_a_number_3
    17  FROM    user_objects;
    JUST_A_NUMBER_1 JUST_A_NUMBER_2 JUST_A_NUMBER_3
                  0               0               0
    SQL>
    SQL> SELECT c1, c2, count(*)
      2  FROM   t
      3  GROUP  BY
      4         c1, c2;
    C1                             C2                               COUNT(*)
    NVL                            F1                                     41
    NVL                            F2                                     41
    CASE                           F1                                     41
    COALESCE                       F1                                     41We can see that NVL executes both functions even though the first parameter (F1) is never NULL. To see what happens in PL/SQL, I set up the following procedure. In 100 iterations of a loop, this will test both of your queries ( 1) IF ..OR.. and 2) bool := (... OR ...) ).
    SQL> CREATE OR REPLACE PROCEDURE bool_order ( rc OUT SYS_REFCURSOR ) AS
      2 
      3     PROCEDURE take_a_bool( b IN BOOLEAN ) IS
      4     BEGIN
      5        NULL;
      6     END take_a_bool;
      7 
      8  BEGIN
      9 
    10     FOR i IN 1 .. 100 LOOP
    11 
    12        IF pkg.f1('ANON_LOOP') = 0
    13        OR pkg.f2('ANON_LOOP') = 1
    14        THEN
    15           take_a_bool(
    16              pkg.f1('TAKE_A_BOOL') = 0 OR pkg.f2('TAKE_A_BOOL') = 1
    17              );
    18        END IF;
    19 
    20     END LOOP;
    21 
    22     OPEN rc FOR SELECT c1, c2, COUNT(*) AS c3
    23                 FROM   t
    24                 GROUP  BY
    25                        c1, c2;
    26 
    27  END bool_order;
    28  /
    Procedure created.Now to test it...
    SQL> TRUNCATE TABLE t;
    Table truncated.
    SQL>
    SQL> var rc refcursor;
    SQL> set autoprint on
    SQL>
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    100
    TAKE_A_BOOL                    F1                                    100
    SQL> ALTER SESSION SET PLSQL_OPTIMIZE_LEVEL=0;
    Session altered.
    SQL> exec bool_order(:rc);
    PL/SQL procedure successfully completed.
    C1                             C2                                     C3
    ANON_LOOP                      F1                                    200
    TAKE_A_BOOL                    F1                                    200The above shows that the short-circuiting occurs as documented, under the maximum and minimum optimisation levels ( 10g-specific ). The F2 function is never called. What we have NOT seen, however, is PL/SQL exploiting the freedom to re-order these expressions, presumably because on such a simple example, there is no clear benefit to doing so. And I can verify that switching the order of the calls to F1 and F2 around yields the results in favour of F2 as expected.
    Regards
    Adrian

  • Work Order list report that will includes Damage and Cause codes

    Is there a WO list report that includes fields of the Damage and Cause Codes?
    Thanks.

    Hi,
    Generally damages and causes  we update in notifications then i think there wont be a list which u r asking
    For notification  the t-code is iw69

  • Anyone know how to stop the "activate" box from blocking usage of a perfectly legal copy of Ilisten? I want to help my dyslexic grandson and this box, including the activation code, keeps popping up, keeping me from using the software. I activated the pro

    Anyone know how to stop the "activate" box from blocking usage of a perfectly legal copy of Ilisten? I want to help my dyslexic grandson and this box, including the activation code, keeps popping up, keeping me from using the software. I activated the program and did a few profile building sessions, now it pops up each time I start the program, blocking me from using it. Help sure would be appreciated.
    Jay

    I looked at your post this morning and did not know enough to respond, other than to find out that links to iListen now go to newer, renamed software. Considering it's been nine hours with no response, I'm suspecting few people here have experience with that software. You could contact the current copmany that used to sell that package and see if they have any archived support info.
    BTW: please check you entry for "Mac OS" in your profile. It says iOS, which cannot run on an iMac. iOS is the system for phone and iPads but can't run on Mac computers. Do "About this Mac" from the Apple menu and see what it says about the OS version. Should look like this:
    If the "Processor" line says "Intel," you have a newer Mac than the old modles this forum covers; Intel iMac have their very own forum here:
    iMac (Intel)

  • Can I include both CSS and HTML codes in one Open HTML Editor.

    Somehow Cell phones are not properly reading css codes. Is there any way to include both CSS and HTML codes in one Open HTML Editor?

    Hammad, their code is fairly mobile friendly.  Per my other discussion with you ( http://topliners.eloqua.com/thread/8532 ), Eloqua's code is responsive for the most part.  Most of their issues lie with the styling of the email where you will get different fonts and different sized fonts throughout the email and some other minor display issues.
    What you are trying to accomplish is extremely difficult to do because you do not have the access to the HTML to better control how the responsive template works which is why the Eloqua templates (and most ESP templates) stick to the more basic side of emails.
    If you want to use Eloqua's WYSIWYG to make their responsive email you can do so, but I would recommend deleting all their body text before editing anything because of the inconsistencies in their code.  Otherwise, I think you would be better off coding the emails outside of Eloqua using a 3rd party editor whether it's something more robust like Dreamweaver or Coda, or whether you feel comfortable working in a more text environment with programs like Notepad++ or Brackets.
    At the end of the day remember you are paying Eloqua for these and if you choose to stick with the WYSIWYG and you are not getting the results you expect you need to tell Eloqua through your support channels.

  • I know my Apple ID (an email and pass code) good,but really I forgot answers the security questions (2-questions) which verify my identity.I can not complete any purchase process for iTunes from another device for example (my personal computer)

    Hi,
    I know my Apple ID ( an email and pass code ) good, really
    I forgot answers the security questions,which verify my identity,
    So it is difficult to complete the purchase process for iTunes Store
    On my PC-FUJI'S,I use Windows Vista home premium as Operating
    System,so reset my secure questions and the answers of course,
    If you please.
    With my respect,
    A signature,
    Mahmoud Fouad El Deeb.

    Hello Mahmoud,
    The steps in the articles below will guide you in setting up your rescue email address and resetting your security questions:
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    Apple ID: All about Apple ID security questions
    http://support.apple.com/kb/HT5665
    If you continue to have issues, please contact our Account Security Team as outlined in this article:
    Apple ID: Contacting Apple for help with Apple ID account security
    http://support.apple.com/kb/HT5699
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • Does ABSL (ByD Script) support Short Circuit Evaluation?

    Hi,
    short question:
    Does ABSL (ByD Script) support Short Circuit Evaluation?
    For example the following code snippet:
    var Call_query;
    Call_query = !this.LastChangeIdentity.IsSet() || (this.LastChangeIdentity.UUID.Content != CurrentIdentityUUID.Content);
    Will "this.LastChangeIdentity.UUID.Content" be evaluated and cause me into trouble if not initialized?
    PS: Is there a language specification available?

    I found something, which looks like a specification.
    See within the Business Center Wiki -> ByD Studio -> Best Practices for Implementation,
    section 'Best Practice for Business Object definition and scripting',
    download ' Syntax for Actions and Events.pdf'.
    Within this PDF, see section 'Logical Expressions'.
    Cite: The logical u201Candu201D (&&) and u201Coru201C (||) operators always evaluate the overall expression to a boolean value (u201Ctrueu201D or u201Cfalseu201D)
    This sounds to me, that Short Circuit Evaluation is not supported.
    BUT: There is no version number nor time stamp nor something else, which points out the status of this document.
    Can someone (from SAP) verify this?

  • Macbook air A1237 short circuiting

    I have just bought a macbook air A1237 the 13 inch screen - it was second hand and had a few problems.
    First problem was once turned on it was show the restart screen and that would be a constant loop, managed to fix that problem so it starts and works properly
    Second Problem - No battery, it wont hold charge - obvious fix replace the battery - need to do,
    Third Problem - No sound, the tricky one.
    The laptop had already been taken to a computer repair shop before i purchased the item - the shop is obvoiusly not competent enough to work on computers due to the fact they could not repair the restart problem (which took a non-computer techie less then 30 mins). and half of the screws from the device are missing - one on the case and all except one on the battery.
    I searched around on the net for a fix for the audio and found a tutorial that said remove the sound ribbon and place it above the battery, so i did this and it worked, turned the machine off and screwed the case back together and no sound... removed the case and i had sound ?? screwed the case back on whilst turned on i had sound for 2-4 hours before it went off... Still only works when the device has no bottom on,
    On anther note when i had the device with no bottom on i leaned over the machine and got a shock on my chin, didnt think anything of this due to the case being open, so screwed it all back together and thought f**k it, its a machine with no sound.
    After talking to a friend who loves his apple products he mentioned that the device could be short circuiting, so i checked the electric shock on my chin again and i got one from the device and every now when using it i get one on my arm or hand??
    So my question is - What could be causing the short and why is the device working properly apart from sound when short circuiting ??  
    Also i have downloaded OS lion - the machine is currently on OS X 10.6.8 and it will not let m upgrade? it starts the upgrade then just crashes ? any ideas?
    Ps. Sorry for my spelling.

    With the keyboard, if working correctly and marked as such, the "3" should also
    have the "#" as an option using the Shift key. There are additional hidden keys
    that these same buttons can provide, conditionally, with use of the "fn" function
    key; this acts like a super-shift key in certain instances. Some keys on a main
    external keyboard are condensed on a portable keyboard, & appear with 'fn'.
    To tell what the keyboard can provide in various alternatives, you could find
    and activate the Keyboard Viewer from within the System Preferences>
    International> Input Menu. With 'visible in menu bar' activated, one can
    more readily access it and the ability to tell what keys and shift, opt, etc
    combinations, or the fn key, can make appear in documents or elsewhere.
    The Keyboard Viewer opens into a small window on the desktop, so keys
    that are pressed are highlighted on a tiny screen in there. You can also click
    on the tiny keys in there to make them work in a document.
    Notice the choices in the Input Menu section, as you can set it so Character
    Palette and Keyboard Viewer both appear under the Flag icon in main Menu
    bar in the Finder or main desktop. Saves having to open Sys Prefs to see it.
    Some of the user interface points of reference change over time or between
    versions of OS X. So do some names of things, esp with Mt Lion/Mav. In a
    way it's good all older Intel-Macs can't run Mavericks 10.9.2. Less trouble.
    Other part sources?
    http://www.macrepairs.co.uk/parts/
    http://www.applemacparts.co.uk/store/macbook-air-c-8130.html
    Anyway, hopefully some of this helps a bit.
    Good luck & happy computing!

  • One short beep and one 1 beep on hp pavilion media center 8120n

    My tower is not booting up when I turn it on.  My son took the side off and was going to put more memory in it for me, but in the end he didn't.  He put the old memory back in and put the side casing back on.  Today, when I turn it on, it has 1 short beep and 1 long beep.  It just won't boot up.  Can anyone tell me what I need to do to get it back up and running?
    This question was solved.
    View Solution.

    RBurke, welcome to the forum.
    The BIOS Beep Code that you are hearing is caused by a memory problem.  Here is a guide that will help solve the problem:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&dlc=en&docname=bph07107
    You should read the entire page.  The beep codes common to HP computers are toward the bottom of the page.
    Please click "Accept as Solution" if your problem is solved.
    Signature:
    HP TouchPad - 1.2 GHz; 1 GB memory; 32 GB storage; WebOS/CyanogenMod 11(Kit Kat)
    HP 10 Plus; Android-Kit Kat; 1.0 GHz Allwinner A31 ARM Cortex A7 Quad Core Processor ; 2GB RAM Memory Long: 2 GB DDR3L SDRAM (1600MHz); 16GB disable eMMC 16GB v4.51
    HP Omen; i7-4710QH; 8 GB memory; 256 GB San Disk SSD; Win 8.1
    HP Photosmart 7520 AIO
    ++++++++++++++++++
    **Click the Thumbs Up+ to say 'Thanks' and the 'Accept as Solution' if I have solved your problem.**
    Intelligence is God given; Wisdom is the sum of our mistakes!
    I am not an HP employee.

  • RequestDispatcher.include and "server-side" include

    I have the following code in a servletA. It will dispatch a servletB within the same webapp. As a result, response content of servletB is included to a original servlet's response. Then servletA can add more data to a response before data is sent back to a client.
    servletB is called from client-side as normal, and then inside the servletA.
    Problem and Question to You:
    If I call servletB within servletA, then responses of these two servlets are merged together. This is a problem here.
    How can I dispatch servletB >>but then do not want to include<< that response data, but skip it. Only the response of servletA should be sent back to a client?
    RequestDispatcher dispatcher =
      getServletContext().getRequestDispatcher("/servlet/testServlet?id=AA");
    dispatcher.include(
      new HttpServletRequestWrapper(env.getRequest()),
      new HttpServletResponseWrapper(env.getResponse())
    );

    Thx and yes, you got it right. Due to a (bad) design, I cannot separate a logic to a standalone bean from servletB and then use that bean. So, I must call it through a url-dispatcher.
    If I'm right, I cannot take a reference to servlets from SessionContext object due to a deprecated-and-not-implemented getServlet method.
    I was hoping, that using a WrapperXXXX class would solve my problem but it did not. I am not sure about why and when should one use that WrapperXXX classes anyway in a dispatcher calls.
    Anyone has a good ideas?

  • SAP Short Dumps and PCI Compliance

    We've run into an issue with our PCI Compliance audit around being able to see unencrypted credit cards in short dump messages in SAP.  Has anyone run into this issue?
    Only work around I've got at this point is to restrict all access to short dumps and require many documented signoffs before turning on and off access to a short dump.  This is pretty cumbersome, and still leaves a hole in my overall security.
    We've managed to purge restricted CC data from our XI logging, and done everything right with encryption, but this short dump issue just doesn't seem to have a solution.
    Can anyone help?  We're on 6.0.
    Thanks!

    Hi David,
    This is an interesting situation you have described. ABAP short-dumps or run-time errors as they are also known as, are unhandled exceptions during program execution. The conditions that cause such exceptions is unknown or cannot be handled at run-time. To help analyze what went wrong with the said program during execution, it is necessary for the dump to contain all possible information including data values passed between programs when the error occurs. Encryption of restricted data values is a program step in itself. If the dump were to occur after this step then of course it would contain encrypted CC info. Unfortunately in your case it exposes restricted CC info because the dump occurs BEFORE this step.
    I don't believe there is a way to prevent this from happening -- for the same reason that the program logic does not know at run-time how to "handle" the exception. If occurrences of such dumps is fairly common in your system, you may want to investigate the likely causes -- for example, missing or incorrect customization. Analyzing the short dumps will probably give you a clue. Your customization team may be able to identify a pre-condition that causes this unhandled exception. If this exception can then be handled (via a program change) that returns a meaningful error instead of a short dump you would be able to close the security hole. This however entails modification to SAP standard code. I don't usually recommend such changes, but given the sensitive nature of your data it may be worth consideration.
    I personally advocate restricted access to ST22. The steps you have undertaken to enforce this may be cumbersome despite efforts to keep it simple. I suppose that's the price we pay in administering the system. If you have not already done so, you may also want to ensure that short-dumps that contain restricted CC info are not saved (using the "Keep" feature in ST22) for easy retrieval at a later point in time or they are saved, it be available only to 'restricted eyes'. Short-dumps are normally saved in the system for 7 or 14 days (not sure of exact # of days). The bigger challenge in my opinion is: How do you prevent the restricted info from being viewed by the user who during the course of program/transaction execution encounters the said short dump? No amount of security controls around ST22 will mitigate this risk. The only option that remains is program change (as mentioned above). But to get there you first need to know what causes the exception.
    Regards.
    Ashutosh

Maybe you are looking for