• 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

how to grab value from arraylist

 
Ranch Hand
Posts: 39
IBM DB2 jQuery Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a arraylist "arrListNewsID.add(sReutersNewsID);"


this arraylist will be like this:
arrListNewsID[urn:newsml:reuters.com:20161114:nL4N1DF2ZE, urn:newsml:reuters.com:20161114:nIFR93G8vf]

Remarks: sReutersNewsID sometime will more than that.




coding for generateJsonObject

When it generator one by one ID, just run method "generateJsonObject(newsContentObj, sFileID);".
i dun wan that my "JSON :" become like this
it suppose like



it suppose one by one ID ID showing
How to show the one by one value from arraylist

 
Ranch Hand
Posts: 270
15
Android Angular Framework Spring AngularJS Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, Sharon:
You need to think a little about control structures' basic syntax.  What you are attempting to do there is "iterate over a collection" (BTW, I did not see how you got your Reuters ID in the first place, but maybe that's just me ).

There are two ways to do that now.  The older way will work, but it is actually more to do.  So I will show you the newer way.  Since I do not know its type, I am assuming the ID is a string.  



This shorthand began to be used sometime around Java 5 (I think).  So, it should be usable.  What's happening here, is the iterator is just hidden from view, and at each pass through the loop, the "nextReutersID" variable is being changed to the next value in the iteration.

Enjoy!
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

L Foster wrote:. . . This shorthand began to be used sometime around Java 5 (I think).  . . .

It was indeed introduced in Java5, in 2004. I think you would describe it as syntactic sugar.
reply
    Bookmark Topic Watch Topic
  • New Topic