Less or less than equal in the for loop condition

Hi,
What do you prefer, what is more common, which one is more easily readable, less or less than equal in the for loop condition?
for (int i = 0; i < arr.lenght; i++){..}
//or
for (int i = 0; i <= arr.lenght - 1 ; i++){..}I know this is basic programming and nothing to do with Java, so if this forum is not for this purpose, could you please suggest a general programming forum?
I would really appreciate it as I have many general questions :)
Thanks in advance,
lemonboston

lemonboston wrote:
Hi,
What do you preferPersonal preference, which is useless to you
, what is more common,Based on years of reading open source code, the first
which one is more easily readable, less or less than equal in the for loop condition?Personal opinion, which is useless to you
I would really appreciate it as I have many general questions :)If you don't want to think about it yourself (which you should be doing in stead of asking general questions), simply attack it lazily. Both examples achieve exactly the same, but the first one is less to type and to read.

Similar Messages

  • Reporting - using the less than function or the filter.

    Hi,
    I am trying to make a report about the opportunities and their values. I decided to add 3 times the same revenue colomn because I wanted the first colomn to show me the revenus under 10000, the seconde one, the revenues between 10000 and 100000 and the third one, the revenues greater than 100000.
    In order to do that, I selected the function button in the creation of my rapport and I tried it 2 different ways.
    1° I choose the filter button (in the function pop up), select the field on my left panel and choose for the first colomn for example "less than" 100000.
    The formula that appears in this one:
    FILTER("- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 USING ("- Revenue Custom Metrics".S_CUR_0 < 100000))
    When I try to execute, I get this error message:
    [nQSError: 10058] A general error has occurred. [nQSError: 22034] Aggregate is not allowed within USING clause of a FILTER operator. (HY000)
    SQL Issued: SELECT "- Account Custom Attributes".PICK_3, "- Opportunity Custom Attributes".TEXT_30, "- Revenue Custom Metrics".S_CUR_0, FILTER("- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 USING ("- Revenue Custom Metrics".S_CUR_0 < 100000)), Opportunity."Current Sales Stage" FROM "Opportunity Analysis"
    2° I try to use the "<" sign without using the filter. So I click on the appropriate colomn and add < 100000, so it becomes:
    "- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 < 100000
    I receive the following error message:
    [nQSError: 10058] A general error has occurred. [nQSError: 27002] Near <<>: Syntax error [nQSError: 26012] . (HY000)
    SQL Issued: SELECT "- Account Custom Attributes".PICK_3, "- Opportunity Custom Attributes".TEXT_30, "- Revenue Custom Metrics".S_CUR_0, "- Revenue Custom Metrics".S_CUR_0+"- Revenue Custom Metrics".S_CUR_0 < 100000, Opportunity."Current Sales Stage" FROM "Opportunity Analysis"
    Can someone tell me what I did wrong ?
    Thanks a lot

    firstly, didn't understand why you are adding the metric to itself in the Fx.
    secondly, you could have used case when statements, something like CASE WHEN metric <10000 THEN metric ELSE NULL END and so forth

  • Only records of less than one day allowed for attendance/absence type 1002

    Hi All,
    I am getting an error while maintaining my sick leave absence type
    "Only records of less than one day allowed for attendance/absence type 1002"
    how to resolve this
    SD

    Bcz recently i made a change like this
    For our sick leave
    "First 14 days(1- 2 weeks) Full Salary
    Next 14 days (3- 4 weeks) 75% Salary
    Next 14 days (5- 6 weeks) 50% salary
    Next 28 days (7- 10 Weeks) 25 % Salary
    More than 10 Weeks no Salary"
    so what i did is
    I mantain one Sick leave type and counting rule as -
    seq no 1 for "First 14 days(1- 2 weeks) Full Salary
    seq no 2  for Next 14 days (3- 4 weeks) 75% Salary
    like this for all the conditions
    and in deduction rule I maintained deifferent Absence quotas
    Plz suggest me this solution will work out
    SD

  • Only records of less than one day allowed for attendance/absence type COMP

    Hi Friends
    I configured all the process in IMG for compensatory off
    ie ,Absence types,Attendance Types ,counting rules and assignment
    but when I tried to create attendances on a particular public holiday in PA 30 then the system shows 'Only records of less than one day allowed for attendance/absence type COMP' (Compensatory Off)
    Anyone pls help me to solve this problem
    regards
    Lakshmi

    Hi
    In PA30 which infotype I should maintain  and where I can see the result.
    Eg If the person works on 25/12/2007(public holiday) ,he wants to take compensatory off on the next working day.
    In this case How I can configure
    Pls help
    Regards
    Lakshmi

  • I have a large PDF that I cannot send via email because of its size, 76 MB. How do I shrink this file or convert it to another format so I can email this, less than 20MB? Thanks for your help

    I have a large PDF that I cannot send via email because of its size, 76 MB. How do I shrink this file or convert it to another format so I can email this, less than 20MB? Thanks for your help

    Open the file in Preview and select "Save as..." from the File menu. Select "Reduce File Size" from the Quartz Filter menu and save. The size probably won't be reduced enough, though. You may have to split the file into several parts and mail them separately. Or upload it to a web server and send the link.

  • Yosemite 10.10.3 update stuck on 'less than a minute remaining' for 2 hours encounting?

    Yosemite 10.10.3 update stuck on 'less than a minute remaining' for 2 hours encounting?
    Anyone else having this?
    Shall I just wait or can i force shut down or anything like that?
    Thanks.

    I ended up having to force quit by holding down the power button after waiting 4 hours to see if it would resolve itself an load.
    Wouldn't boot up properly, seemed to be stuck on the new apple logo with loading bar below so forced quit again and tried to restore form a time machine back up by holding cmd+R on restart. It said it was unable to do this so restarted again and it eventually started as normal and I was running 10.10.3 although I wasn't sure if the install was done correctly so did complete a restore from a time machine back up.
    I think I will wait for another .1 update or just try again at a later date maybe.
    Thanks.

  • HT5568 When I attempted to update this, it didn't finish.  Stopped indicating there was less than a minute remaining for over 45 minutes. Any suggestions?

    When I attempted to load the latest security update, it did not finish indicating less than a minute remaining, for 45 minutes.  Any Suggestions?

    Contact Apple Service, iMac Service or Apple's Express Lane.

  • HT1848 On itunes, when synced to my pc, I show less than half of the music that is on my iphone 4. How do I get all the music onto my pc?

    I am about to scream if I don't figure this out or just decide to leave Apple and get a Galaxy phone. On itunes, when synced to my pc, I show less than half of the music that is on my iphone 4. How do I get all the music onto my pc? I have read many forums and tried many things, but apple/iTunes is not intuitive at least not on a PC. When I go to devices it won't let me select "transfer music". It's grayed out. Why is this and what can I do? I'd like to delete some of the music off of my iPhone but don't want it gone forever. Pleae help.

    Thanks Turingtest2,
    I appreciate your response. I have done all of the things mentioned, but still when I click on "devices", the "transfer music" option is still not selectable. I see it, but can't select it.  I am running Windows 7 on my PC.
    However, one thing I read makes me take pause. At one point I did erase my computer back to factory settings using the mirrored image. We backed up all information and put the important stuff back on, but I don't believe we did anything with iTunes, so it's a possibility that the music that is in my library now, may only be music I have purchased since then. But, (thinking out loud) that was a while ago and I am pretty sure I have purchased more music than what is in my iTunes library, since then.  Maybe I will approach it from that angle and see what happens.
    It just doesn't make any logical sense that syncing goes from computer to device. Ostensibly then, my iPhone would only have the music that is on my computer after syncing and that is not the case. I still have all my music on my phone. I can see the new music that's on my phone get added to my iTunes library when I connect, which would make one think that syncing occurs both ways. I don't know. It's maddening. Maybe I should just follow my husbands advice and go to an Android. LOL. Or maybe I will take my laptop and phone to the Apple store and make them figure it out. Ha.
    If you have any thoughts about this, let me know. Thanks again.

  • Is it possible to import less than ALL of the data from a PDF form developed on LiveCycle?

    Is it possible to import less than ALL of the data from a PDF form developed on LiveCycle?

    Please ask in the LiveCycle Designer forum.

  • "Less than a minute remaining" for over a few hours with Migration Assistant

    Hi everyone,
    I am migrating to a MBP Retina running latest 10.7. I am using migration assistant to import a user from my new Time Capsule.   It's stuck on "Less than a minute remaining" for over a few hours that I noticed it.  What should I do?
    (Yes, I am on Wireless N and I do not own a ethernet adapter)
    Any help,suggestion, wait/not wait?
    Thanks,
    Chester

    my recommendation stems mostly from what others have replied to similar posts. I personally think it is probably done, and a hard shut down and restart will probably work. but also see this good reply from WZZZ
    https://discussions.apple.com/thread/5050660

  • The demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.

    the demand of my application is that i can not replace for loop with a while loop.because i need fixed number of iterations and as far as i know fixed iterations could be only with possible with the for loop.
    your recommended second option that i could add true/false case.
    this true/false case must be inside the for loop or outside the for loop?if this case is inside the for
    loop, how can i send stop command from outer while
    loop?
    more over do you have any example for this please?
    thanks"

    You can execute a fixed number of iterations using a while loop by comparing the iteration count to the number of iterations you want and wiring the output of that comparison (e.g. Less Than or Equal To) to the continue (or stop) terminal of your while loop. Which comparison you use depends on personal preference, where you wire the desired count and the interation count, and whether you're using the while loop as Continue if True or Stop if True.
    Ben gave you step-by-step instructions in response to your previous question. Look here for Ben's response.
    Ben's response looks pretty good and detailed to me. It certa
    inly deserved better than a 1-star rating.

  • How to code a parallel 'for loop' and 'while loop' where the while loop cannot terminate until the for loop has finished?? (queues also present)

    I've attached a sample VI that I just cannot figure out how to get working the way that I want.  I've labeled the some sections with black-on-yellow text boxes for clarity during the description that follows in the next few sentences.  Here's what I want:
    1) overall -- i'm intend for this to be a subVI that will do data acquisition and write the data to a file.  I want it to use a producer/consumer approach.  The producer construct is the 'parallel for loop' that runs an exact number of times depending on user input (which will come from the mainVI that is not included).  For now I've wired a 1-D array w/ 2 elements as a test case.  During the producer loop, the data is acquired and put into a queue to be delt with in the consumer loop (for now, i just add a random number to the queue).
    2) the consumer construct is the 'parallel while loop'.  It will dequeue elements and write them to a file.  I want this to keep running continuously and parallel until two conditions are met.
          i. the for loop has finished execution
          ii. the queue is empty.
       when the conditions are met, the while loop will exit, close the queue, and the subVI will finish. (and return stuff to mainVI that i can deal with on my own)
    Here's the problems.
    1)  in the "parallel for loop" I have a flat sequence structure.. I haven't had time to incorporate some data dependency into these two sequential sections, but basically, I just care that the "inner while loop" condition is met before the data is collected and queued.  I think I can do this on my own, but if you have suggestions, I'm interested.
    2)  I can easily get the outer for and while loops to run sequentially, but I want them to run in parallel.  My reasoning for this is that that I anticipate the two tasks taking very different amounts of time. .. basically, I want the while loop to just keep polling the queue to get everything out of it (or I suppose I could somehow use notifiers - suggestions welcome)...  the thing is, this loop will probably run faster than the for loop, so just checking to see that the queue is empty will not work... I need to meet the additional condition that nothing else will be placed in the queue - and this condition is met when the for loop is complete. basically, I just can't figure out how to do this.
    3) for now, I've placed a simple stop button in the 'parallel while loop', but I must be missing something fundamental here, because the stop button is totally unresponsive.  i.e. - when I press it, it stays depressed, and nothing happens.
    suggestions are totally welcome!
    thanks,
    -Z
    Attachments:
    daq01v1.vi ‏59 KB

    I'd actually like to add a little more, since I thought about it a bit and I'm still not quite certain I understand the sequence of events...
    altenbach wrote:
    zskillz wrote:
    So i read a bit more about the 'dequeue element' function, and as I understand it, since there is no timeout wired to the dequeue element function, it will wait forever, thus the race condition I suggested above can never happen!
    Yes, you got it!
    As I've thought about it a bit more, there's a few things that surprise me... first, the reason the 'dequeue element while loop' errors is not because there's nothing in the queue, it's becaues the queue has been released and it's trying to access that released queue...   However the problem I have is this --- Even though there's no timeout wired to the dequeue element, I still would think that the while loop that contains it would continue to run at whatever pace it wanted -- and as i said before.. most of the time, it would find that there is nothing to dequeue, but once in a while, something is there.  however, it seems that this loop only runs when something has been enqueued.  the reason I say this is illustrated in the next code sample MODv2 that's attached below.  I've added a stop button to the "queue size while loop" so the program runs until that is pressed.  I've also added a simple conditional in the "dequeue while loop"  that generates a random number if it a button is pressed... but this button is totally non-responsive... which means to me that the "dequeue while loop" isn't actually continuously running, but only when an element is added to the queue.  this still seems almost like the 'dequeue while loop" waits for a notifier from the queue telling it to run.  can you explain this to me? because it is different from what I expect to be happening.
    rasputin wrote:
    I tried to open your VIs but it doesn't work. LV
    is launched, the dialog box (new, open, configure...) opens and then...
    nothing. Not even an error message. I guess it isn't a problem of LV
    version or a dialog box would appear saying this. Could you, please,
    send a image of the code?
    Thanks,
    Hi Rasputin, I'm using LV8.  I assume that was your problem, but who knows.  I've attached a pic of of altenbach's solution since it's what I needed.
    thanks
    -Z
    Message Edited by zskillz on 10-20-2006 11:49 AM
    Attachments:
    daq01v1MODv2.vi ‏63 KB
    daq01v1MODpic.JPG ‏116 KB

  • [svn:bz-trunk] 21048: moving the locking of MessageService. subscribeLock one level up in the for loop.

    Revision: 21048
    Revision: 21048
    Author:   [email protected]
    Date:     2011-04-08 06:47:21 -0700 (Fri, 08 Apr 2011)
    Log Message:
    moving the locking of MessageService.subscribeLock one level up in the for loop.
    in case of multiple subscribers, we only lock once
    checkintests pass
    Modified Paths:
        blazeds/trunk/modules/core/src/flex/messaging/services/MessageService.java

    I have finally been able to replicate the behavior that you are seeing on another computer once the image was large enough.  Here are a few notes about this behavior:
    First. The UI only slows down when the images are large, 16 bit images.  The reason why this is unique to 16 bit images is that they can only be displayed on the front panel as 8 bit images.  The workaround that Weiyuan suggested to change the 16 bit display mapping hints towards the root of the problem...that any time a mouse runs over the indicator, Windows asks the entire image to re-draw (having a separate indicator overlapping the image will create the same behavior).  With a 16 bit image, not only does the image have to re-draw on the screen but the 16 bit pixels need to be mapped to 8 bits.  When setting the 16 bit display mapping to Full Dynamic, this requires mor computation/pixel than 90% dynamic or one of the other mapping schemes.
    This is expected behavior if your program is running and you're trying to display a large 16 bit image.  To fix this behavior there are a couple options:
    Change the 16 bit display mapping to something other than full dynamic.  You can choose which 8 bits to display or if you want to map the bits. 
    Resize the image just for viewing purposes on your front panel (since you aren't going to view every single pixel of you image on the screen). You can use the IMAQ Resample.vi to do this.  This will allow you to take your 1500x1500 pixel image and only display a 500x500 pixel version.
    If you are interested in viewing small details of the large image, consider just displaying a smaller region of interest at a time.
    Let me know if any of these solutions work for you.  Good luck on your application.
    Zach C.
    Field Engineer
    Greater Los Angeles

  • Need help with the for loop

    Hello,
    I hope someone can point me in the right direction for my next assignment. I am very new at Java programming. For my next assignment for class I will need expand my previous program which was a mortgage calculator. The first assignment we wrote a program to show the monthly payments of a $200,000 loan at 5.75% for 30 years. Now we have to output all 360 monthly payments with pauses in between so it doesnt scoll off the page. The calculation that we use is:
    month_payments = (principle * monthlyinterest) / (1-Math.pow(1 + monthlyinterest, - months));
    My question is how do I get the correct calculation outputed 360 times. I would like to use the "for loop" to do this. Also what is the correct way to do the pause command? I do not want someone to write the code, I just want some help to where I need to start off, I want to learn this on my own.
    Thanks in advance,
    DC

    for (int i ; i < 10 ; i ++ ) { System.out.println("Come sail away"); }
    or;
    int i = 0;
    while(i < 10)
        i++;
        System.out.println("Come sail away");
    }

  • How to control the looping time of the for loop in 10 microseconds in labview?

    I need to create a +/- 9 volt square wave with period of 20us using a D/A card (Not NI card). I can write command to the card using outport provide by Labview. Right now, I can generate square wave with 4ms period which is limited by the resolution of the wait until next ms icon I used inside the for loop. Could anyone tell me how to control the execution time of the for loop to about 10 us? Your help would be much appreciated.

    I'm not sure if this will hep, but this answer seems to answer this question
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000029410000&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=microsecond+resolution+1ms&USEARCHCONTEXT_QUESTION_S=0

Maybe you are looking for

  • Report manager of a person in HR

    Hi - Can anyone advise on how to report the manager of a person - the problem being that many of our chief positions are currently empty.  In this case we need to walk up the Org Structure, find the next occupied position and report the person in tha

  • Where is the sign in page from the itunes menu

    I am trying to add an iphone device to my apple id or itunes account, when I do a google search for it, they all say to choose store > sign in  from the itunes menu.  Where is this?  I have tried multiple times and I am not able to even find that pat

  • Removal of Reservation on Process Order Locking

    Hi Experts, I'm unable to clear the reserved materials under a Process Order after Locking the same. Is it possible to release the reserved material after locking an Order? Regards Subhasis

  • PFCG - Copy menu description problem.

    Hi, I  have  created one user (PP module) using  the tcode (SU01) &  then  created Customized role in the Tcode : PFCG. User & role created sucessfully.  while i inserting Role in the PFCG under the Menu Tab ->Copy menu -> From SAP Menu It shows only

  • Diffrent Between Goods Receipt Transaction Code MB01 and MIGO?

    Dear All Could anyone please tell me different between goods receipt by MB01 and MIGO. Should I choose MIGO or MB01. Thank and Best Regards, Thang