JAVA + create HashMap in place of function -


i write following 2 functions want implement functions hashmap ( in place of functions ) how that?

static void somefunction(int count, int[] anarray)   {         ( int i=0;i<anarray[count];i = + 1)    {     system.out.print("#");   }   system.out.println(""); }   static void somefunctionb(int[] anarray , int count,  string stringfinal, string sttr)   {         anarray[count]= stringfinal.replaceall("[^"+sttr+"]", "").length(); }     somefunctionb(anarray ,  count,   stringfinal,  sttr  );          somefunction(count, anarray);   

without using functions (apart public static void main(string[] args)), like:

map<integer, integer> mapthatpretendstobeanarray = new linkedhashmap<integer, integer>(); mapthatpretendstobeanarray.put(0, 17); mapthatpretendstobeanarray.put(1, 5); mapthatpretendstobeanarray.put(2, 1); mapthatpretendstobeanarray.put(3, 319);  //somefunction() (int = 0; < mapthatpretendstobeanarray.get(1); i++) {     system.out.print("#"); } system.out.println("");  //somefunctionb() mapthatpretendstobeanarray.put(3, "stringfinal".replaceall("[^"+"sttr"+"]", "").length()); 

but of course, somefunction() , somefunctionb() more useful, because let parameterize arguments instead of having pick hard-coded ones in example.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -