GeeCON Prague 2014*
The moose likes Java in General and the fly likes Regarding Map Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Regarding Map" Watch "Regarding Map" New topic
Author

Regarding Map

Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,,
i was going through the below piece of code...



Could you please explain me wha'ts this code is doing, .. as per my understanding ...it is storing key as 1 and it corresponding value as Home..similar the other also it is storing...!!please advise it is doing technically what I have understood..!!
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saral Saxena wrote:Hi Folks,,
i was going through the below piece of code...



Could you please explain me wha'ts this code is doing, .. as per my understanding ...it is storing key as 1 and it corresponding value as Home..similar the other also it is storing...!!


You don't need anybody to help you with that. You can see what it's storing for yourself. Call println() to see key and value before it put()s them, and/or print out the contents of the map after the put() call.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

Saral Saxena wrote:as per my understanding ...it is storing key as 1 and it corresponding value as Home.


I never really remember how the String.substring() method works and I always have to look it up when I use it. And even then I sometimes get off-by-one errors. So yes, I would agree with Jeff, use System.out.println to confirm (or deny) what you think is happening.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Paul Clapham wrote:
Saral Saxena wrote:as per my understanding ...it is storing key as 1 and it corresponding value as Home.


I never really remember how the String.substring() method works and I always have to look it up when I use it. And even then I sometimes get off-by-one errors. So yes, I would agree with Jeff, use System.out.println to confirm (or deny) what you think is happening.


And also look at the substring() docs, if you're not sure what that does.

To summarize, there's no need for you to continually act so helpless. A lot of the questions you post can be answered--or at least a good start to an answer can be found--by you simply engaging your brain and spending a little time researching.
Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Hi Folks,,
i was going through the below piece of code...




Can you please advise me , that the same thing can be also achieved with string , split() method also, and if yes then could you please show me the conversion of above program of mine into string split() specification..!!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4572
    
    5

Saral Saxena wrote:Can you please advise me , that the same thing can be also achieved with string , split() method also, and if yes then could you please show me the conversion of above program of mine into string split() specification..!!


You first. Read the API and a regex tutorial or two and post your best efforts if it doesn't work out, along with a clear description of your desired and actual results.

And in future, UseOneThreadPerQuestion <-- link and don't mix disparate question in the same thread as you have done here.


luck, db
There are no new questions, but there may be new answers.
Saral Saxena
Ranch Hand

Joined: Apr 22, 2011
Posts: 202

Saral Saxena wrote:Hi Folks,,
i was going through the below piece of code...




Can you please advise me , that the same thing can be also achieved with string , split() method also, and if yes then could you please show me the conversion of above program of mine into string split() specification..!!


Hi Folks , Please advise me..!!
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How many more times are you going to post this question without paying any attention to what people answer? Come to think of it, that goes for a lot of your questions.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saral Saxena wrote:
Hi Folks , Please advise me..!!


You've already been advised. As Darryl said:

Darryl Burke wrote:
You first. Read the API and a regex tutorial or two and post your best efforts if it doesn't work out, along with a clear description of your desired and actual results.

And in future, UseOneThreadPerQuestion <-- link and don't mix disparate question in the same thread as you have done here.
 
GeeCON Prague 2014
 
subject: Regarding Map