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

Different results with println and add to list

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

I dont really understand whats going on here...


I am accessing User permissions from the server, and looping through the subcategories...
when I println the variable I get the exact result Im looking for, but when I add each instance of the variable to a list; the list doesn't give the same result.

also I am using a break; to jump out of the loop because it was printing the last line twice and I didn't know why?

here is a bit of the code...





This is how I want the permissions to be output
12345


if I print the list inside the loop I get this...
where they are numbered 11111
I understand that the output is repeated...its printing the first then first & second
and so on...but there is a straggling bit of code at the end?


If I print the list outside of the loop, all I get is the straggler?





I have a few more questions regarding this same project
(but I'll pace myself...this is my first real java project, and I am running in to a lot of (at least seemingly) anomalous results)
any help would be greatly appreciated.
Thanks.



 
I will open the floodgates of his own worst nightmare! All in a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic