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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

desired result from println not so much with add to list

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

I dont really understand whats going on here...
how is it possible to get different results from add to list and println?
especially if they are being executed on the same line?
is it possible to output to a string from outputstream?
That option seems silly.
I might be doing all of this the hard way?

I have sort of "dived in" to programming in general.

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?
(not sure if thats a bad idea)
here is a bit of the code...

I have attached some screenshots of the console output as well...

This is how I want the permissions to be output...when I println I get this result...

if I print the list inside the loop I get this...where they are numbered
I understand that the output is repeated...building on top of itself as it loops...but there is a straggling bit of code at the end?

lastly...If I print the list from outside the loop...its totally messed up...only the straggling end piece shows up...

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.
Posts: 76862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You may have a lot of questions, but we don’t like them in lots of places, as you will see from this link. This discussion seems to similar to this thread that (Rob, Roberto, Martin, Stephan, I hope you don’t mind) I am closing this discussion.
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic