I write the following two functions
I want to implement the functions with HashMap ( in place of functions )
how to do that?
static void someFunction(int count, int[] anArray)
{
for ( int i=0;i<anArray[count];i = 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 any functions (apart from
public static void main(String[] args)), you could do something like:But of course,
someFunction()andsomeFunctionB()are more useful, because they let you parameterize your arguments instead of having to pick hard-coded ones as in this example.