• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

werid output for For loop

 
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all
I'm facing a weird problem with for loop , here is my code



this is the output



you will find my questions as comments in the code and the output . what i wanna do is when i = 0 it goes to the inner for loop till x reaches 28 then increment i by ...etc till i reaches 13 ..

Any thing i was missing ?

Happy new year to all
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're printing to two different print streams that aren't synchronized -- System.err and System.out. Why?
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darryl Burke:
You're printing to two different print streams that aren't synchronized -- System.err and System.out. Why?



Opps, what a silly stuff i missed , may be i need to rest i'm working for 13 hours till now , ya i just made all System.out and working fine now
 
S Shehab
Ranch Hand
Posts: 493
Android Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Darryl Burke:
You're printing to two different print streams that aren't synchronized -- System.err and System.out. Why?



why when i'm printing this inside the inner loop giving me this exception
 
author
Posts: 3285
13
Mac OS X Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because there is no element at position x for that list. I'd also split out your code a little so that you can clearly see when you are accessing what.
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sherif Shehab:


why when i'm printing this inside the inner loop giving me this exception



Because either the inner or outer vector used in vBckTableTotal is empty, and so doesn't have an index 0.
 
reply
    Bookmark Topic Watch Topic
  • New Topic