This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

A question about Maps and splitting Strings  RSS feed

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So I'm doing a small task where I need to display a user entered URL's parameters. This is the code I found as a possible solution. But I can't understand why is it you can put a split String into a Map that has String for both key and value and the split method returns a String array. I obviously can't wrap my head around on why are the square brackets added after calling the split method. Is that supposed to be the index of the returned array? Care to explain fellas?

Glad to be back on the ranch, after a long pause (needed some extra knowledge to be comfortable to ask questions ), cheers.
 
Marshal
Posts: 64473
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Darko Jakimovski wrote:. . . why are the square brackets added . . . the index of the returned array? . . .

The number inside the [] is the index of the array element, yes. The String#split() method returns String[], so myString.split(someRegex)[999] represents a single String.

Glad to be back on the ranch, after a long pause (needed some extra knowledge to be comfortable to ask questions ), cheers.

Good to see you back. You would have got much extra knowledge by asking questions here.
 
Darko Jakimovski
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. And yeah... I realized that the second I posted my question. I figured it out once I asked the question myself in a forum form
 
Campbell Ritchie
Marshal
Posts: 64473
225
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pleasure. Plese search for “rubber duck programming”. For example Wikipedia. Don't read the story about quack overflow.
 
Darko Jakimovski
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OMG! Thank you so much. I had issues in the past few days because of my total lack of knowledge in debugging. Campbell, you are the man!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!