Skip to main content
se añadieron 25 caracteres en el cuerpo
Origen Enlace

ES mejor usar un HasMap

myArray:int myArray[] =( new int[]{1, 2, 1, 3, 3, 1, 2, 1, 5,1) 
 1};

public static void main (String args[]) {
   HashMap<Integer, String> hash = new HashMap<>();
  hash.put(5, "");
  hash.put(4, "");
  hash.put(3, "");
  hash.put(2, "");
  hash.put(1, "");
  
  for (int i = 0; i < myArray.length; i++){
    hash.put(new Integer(myArray[i]), hash.get(myArray[i])+"*");
  }
  
  for(Integer key: hash.keySet()){
    System.out.println(key+": "+ hash.get(key));
  }
}

ES mejor usar un HasMap

myArray:=(1,2,1,3,3,1,2,1,5,1) 
 

public static void main (String args[]) {
   HashMap<Integer, String> hash = new HashMap<>();
  hash.put(5, "");
  hash.put(4, "");
  hash.put(3, "");
  hash.put(2, "");
  hash.put(1, "");
  
  for (int i = 0; i < myArray.length; i++){
    hash.put(new Integer(myArray[i]), hash.get(myArray[i])+"*");
  }
  
  for(Integer key: hash.keySet()){
    System.out.println(key+": "+ hash.get(key));
  }
}

ES mejor usar un HasMap

int myArray[] = new int[]{1, 2, 1, 3, 3, 1, 2, 1, 5, 1};

public static void main (String args[]) {
   HashMap<Integer, String> hash = new HashMap<>();
  hash.put(5, "");
  hash.put(4, "");
  hash.put(3, "");
  hash.put(2, "");
  hash.put(1, "");
  
  for (int i = 0; i < myArray.length; i++){
    hash.put(new Integer(myArray[i]), hash.get(myArray[i])+"*");
  }
  
  for(Integer key: hash.keySet()){
    System.out.println(key+": "+ hash.get(key));
  }
}
Origen Enlace

ES mejor usar un HasMap

myArray:=(1,2,1,3,3,1,2,1,5,1) 


public static void main (String args[]) {
   HashMap<Integer, String> hash = new HashMap<>();
  hash.put(5, "");
  hash.put(4, "");
  hash.put(3, "");
  hash.put(2, "");
  hash.put(1, "");
  
  for (int i = 0; i < myArray.length; i++){
    hash.put(new Integer(myArray[i]), hash.get(myArray[i])+"*");
  }
  
  for(Integer key: hash.keySet()){
    System.out.println(key+": "+ hash.get(key));
  }
}