Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

A question about Maps and splitting Strings

 
Ranch Hand
Posts: 58
1
  • 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: 69403
276
  • 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
Ranch Hand
Posts: 58
1
  • 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: 69403
276
  • 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
Ranch Hand
Posts: 58
1
  • 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!
 
What are your superhero powers? Go ahead and try them on this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic