class Flot { private Map<Integer,String> korabel = new HashMap<>(); public Map<Integer,String> func(int[] mass,String[] mass2, int Size){ Random rand; for(int i = 0; i < Size; i++){ int size = mass[(int)(Math.random()*3)]; String str = mass2[(int)(Math.random()*3)]; korabel.put(size,str); } return korabel; } public void seefunc(){ for(Map.Entry<Integer,String> mapa : korabel.entrySet()){ System.out.println(mapa.getKey() + " " + mapa.getValue()); } } } public class Main { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); Flot flot = new Flot(); int[] mass = {30 ,50, 100}; String[] mass1 = {"ananas", "banan", "apple"}; int size = Integer.parseInt(reader.readLine()); flot.func(mass,mass1,size); flot.seefunc(); } } 
  • Describe how the program should work - Anton Sorokin
  • 2
    and should not, judging by the code you have 3 possible keys 0, 1 и 2 - Stranger in the Q
  • @AntonSorokin. The size of random elements should be added to "korabel". - Vlad Lukiuanchuk

0