How to get count from new enhanced for loop

Is there a better way to determine the count when new enhanced for loop is used as follows:
String[] test = new String[]{"1","2","3"};
int count = 0;
for(String i: test)
count++;
system.out.println("count: "+count);
}

There are cases where I need to use the count inside
the for loop. I can keep track of the count by using
the increment. But, then I would rather using the old
for loop. Go ahead and use it. Are you under the assumption that the old form should be avoided?
There is no saving in term of efficiency and readability.If there is any added efficiency in the "for each" form of the loop, it is on the micro level, and you would never notice it.
As far as readability, look at some of the crazy solutions you've been given to avoid the general for loop, then reconsider which is more readable.

Similar Messages

  • How to get "Count" from CAF's Application Service

    hi
    i want know how many data in my entity, i can use "findAll" and read the List's size.
    but it will waste resource.
    have any other way to get the count from entity?

    seem no way.

  • How to get data from the user for an Insert Trigger ?

    Hi all and thanks in advance, I need to get some values from the user for a child table when a row inserted into the parent table, is that possible to use ampersand inside an "Insert Trigger" to let the user for inserting some values ?
    Edited by: user9942078 on 17-Dec-2008 16:35

    In a different words,
    When a virus attacked your body your blood cells instantly goes into operation. Just like that -> your trigger activated as a result of your DB operation on objects. So, here also you have no option to manually intervene anything.
    Hmm... Looks like some science fiction movies ultimately pays some price... ;)
    So, trigger basically fires implicitly as a result of any database operation on objects or even on user.
    So, that has to be automatic. And, when you are using & it will ask for some input value - which cannot be done in case of triggers.
    For details please refer the oracle docs.
    Regards.
    Satyaki De.

  • How to get notification of new post  for any discussion topic

    hi,
    i ve started a discussion in portal and i want to get notification for any new post to that discussion topic in my uwl....can anybody help me
    thanks in advance
    Message was edited by: Amit Pandey

    Have a look at this:
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/b03a381dc88d49b1f509cde90a27d1/frameset.htm
    This should help solve it!

  • I have a new MacAir and don't know how to get info from my USB stick and my SD photo card.  Can anyone help me please?

    I have a new MacBook Air and don't know how to get info from my USB stick and get info from my SD card.  Can anyone help, please?

    Plug the stick and/or card into the appropriate slots on the side of your Air. Do you see icons for the devices appear on the desktop? Click into them to see what files are there.
    Matt

  • How do I create a new calendar for the current year, using last years calendar's birthday's/photos and comments from the lower pages?

    Each year for the past 5 years I make a family calendar and send copies to all he family members around the globe.  I hate that I have to recreate all the birthdays and special occasions from scratch, and re-drag all the photos onto these dates, in the lower half of the page of each month on the new calendar.  How can I create a new calendar for the current year and port all of these photos/comments into the new calendar from last years calendar, to save having to redo all this work!!  I am not talking about the upper half page of the photos only...I am referring to the calendar page of each month.
    Thanks in advance. 
    Colin

    Welcome to the Apple Discussions. Open iWeb so you see your original site in the left hand pane. Use the File->New Site menu option to create a new site. Give it the name you want.
    Now select a page in your original site and type Command+D. That will duplicate the page. Drag the duplicate page down to the new site and rename it as needed. Do that for the other pages you need in the original site.
    OT

  • I got a new computer and don't know how to get music from ipod touch to itunes library

    I recently got a new computer and don't know how to get music from my ipod touch to show on my itunes library. 

    You need to transfer the iTunes folder from the old computer to the new one.
    iTunes: How to move your music to a new computer (Mac or Windows):
      http://support.apple.com/kb/HT4527

  • How to get photos from camera or memory card into new macbook?

    how to get photos from camera or memory card into newly announced macbook?  thank you   joanlvh

    And to diversify the use of that port, you could get this specialized adapter:
    http://store.apple.com/us/product/MJ1K2AM/A/usb-c-digital-av-multiport-adapter
    The cost of admission is modest - at $79 - for what all that it does.

  • How to get count of rows for a table?

    Hi,
    How to get count of rows for a table and secondly, how can i have access to a particular cell in a table?
    Regards,
    Devashish

    Hi Devashish,
    WdContext.node<Your_node_name>().size() will give you the no: of rows.
    This should be the node that is bound to the table's datasource property.
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value); will select the row at that particular index.
    You can access an attribute of a particular row as
    WdContext.node<Your_node_name>().get<node_name>ElementAt(index_value).get<attribute_name>();
    Hope this helps,
    Best Regards,
    Nibu.
    Message was edited by: Nibu Wilson

  • How do I burn a new CD for my car from my ipod touch.

    I lost my CD but my album is on my ipod touch.  How do I burn a new CD for my Car.  Yes I did purchase the original CD, but not on Amazon or the itunes store.

    You cannot from the ipod touch.
    As the music came form your computer in the first place, it should still be there (you should also always have a backup copy).

  • I have registered a credit card for purchasing apps from the app store. My bank has issued a new chip based card and now the 16 digit numbers have changed. How do I register the new card for flowless purchases?

    I have registered a credit card for purchasing apps from the app store. My bank has issued a new chip based card and now the 16 digit numbers have changed. How do I register the new card for flowless purchases?

    Go to Apple Menu > App Store > View my account > sign in and then edit the payment details with the new card details.  
    I am assuming that your card and supporting bank are in the same country as your residential (billing) address and that you are using the App Store of that country.

  • How can i get a brand new case for my iphone

    I NEED TO GET A BRAND NEW CASE FOR MY IPHONE BECAUSE MY IPHONE IS DENTED ON THE BACK AND SCRATCHES ALL OVER THE PHONE, IF SOMEONE CAN HELP ME I WILL APPRICIATED.

    You can start by not using all caps - using all caps on the internet is considered as SHOUTING and hopefully you didn't intend to be shouting at all those who read your post.
    When you say case, do you mean the iPhone casing itself?
    If so, you can contact AppleCare for a quote to repair this damage which won't be cheap. I believe there are some 3rd party repair facilities available that will do the same won't be cheap but maybe somewhat less than what Apple will charge.
    Or purchase a case for the iPhone to cover the dents and scratches and to protect it from additional damage with future drops.

  • HT1498 Horrible experience and the movie kept stalling through iTunes on appletv. Gave up (after paying for it) and ended up renting it through cable provider. Anyone know how to get $ back from apple?!

    Horrible experience and the movie kept stalling through iTunes on appletv. Gave up (after paying for it) and ended up renting it through cable provider. Anyone know how to get $ back from apple?!

    Issues are usually network related
    What is your internet speed? www.speedtest.net
    6mbps is required for instant HD (you can switch to SD in the settings)
    If on wifi try ethernet and www.istumbler.net to rule out interference
    Make sure you're using your ISP's DNS

  • How to get playlist from old ipod to new itunes

    how to get playlist from old ipod to new itunes

    See Recover your iTunes library from your iPod or iOS device.
    tt2

  • I am switching from an iphone 4s to a 5s. When I try to restore from icloud and then choose a backup, it tells me "No iCloud backups are compatible with the version of iOS on this iphone." How can get into my new phone to update?

    I am switching from an iphone 4s to a 5s. When I try to restore from icloud and then choose a backup, it tells me "No iCloud backups are compatible with the version of iOS on this iphone." How can get into my new phone to update?

    UUpdate the new iphone to iOS 8.3 before you try to restore the backup.

Maybe you are looking for

  • I can no longer click and drag Safari window to the other desktop.

    I've tried merging all windows and minimizing that single window, then going to the other desktop to open up the window.  That doesn't work--it just opens on the original desktop.  When double-clicking on the Safari icon in the dock, the options for

  • Radius authentication with ISE - wrong IP address

    Hello, We are using ISE for radius authentication.  I have setup a new Cisco switch stack at one of our locations and setup the network device in ISE.  Unfortunately, when trying to authenticate, the ISE logs show a failure of "Could not locate Netwo

  • Open pdf in IE using #toolbar = 0 does not display read mode menu

    I m trying to open up a pdf document using IE 9 and Adobe Reader XI and if I have the toolbar hidden the first time the document displays the read mode menu bar does not display.  I have to refresh the browser to get the read mode menu to display. Ho

  • Oracle 10g migration to linux

    Hi, At present we are maintaining a J2EE application running on a UNIX Platform with the following environment configuration: o Web Server (Apache 2.0.52) o Application Server (WebLogic Server 9.0) o Database Server (Oracle 9i) The current requiremen

  • Power button fails to work about 95% of the time

    Hello, I have a Toshiba P205-S6267 that is having a strange issue. About 95% of the time the power button fails to work when on battery, and it fails 100% of the time when the AC adapter is plugged in. I am getting pretty stumped on this one and star