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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

A little confused with the code....

 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What happens when the Junk2 is executed?How the execution proceeds?I'm a bit confused about what happens at (1),(2),(3) during execution?How and where the values are stored?

public class Junk1 {
public Junk1(){
hm = new HashMap[1]; ...............(1)
hm[0] = new HashMap(); ..............(2)
}
public boolean put(Object key,Object value){
if(value !=null){
hm[current].put(key, value);.........(3)

return true;
}
else return false;
}
HashMap hm[];
private int current =0;
}

---------------------------------------------------------------------------

public class Junk2 {


public static void main(String[] args) {
Junk1 jn = new Junk1();
jn.put("emp_id", args[0]);
jn.put("name", args[1]);
jn.put("password",args[2]);


}

}
--------------------
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Don't post the same question in multiple forums
 
I don't always make ads but when I do they're tiny
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic