Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
[COLOR=#000000][COLOR=#0000CC]int[/COLOR][COLOR=#006600][] [/COLOR][COLOR=#0000CC]zahlen [/COLOR][COLOR=#006600]= {[/COLOR][COLOR=#0000CC]1[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]4[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]5[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]99[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]103[/COLOR][COLOR=#006600]};[/COLOR][/COLOR]
[COLOR=#000000][COLOR=#0000CC]int[/COLOR][COLOR=#006600][] [/COLOR][COLOR=#0000CC]zahlen [/COLOR][COLOR=#006600]= {[/COLOR][COLOR=#0000CC]1[/COLOR][COLOR=#006600] 1, [/COLOR][COLOR=#0000CC]4[/COLOR][COLOR=#006600] 2, [/COLOR][COLOR=#0000CC]5 1[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]99 2[/COLOR][COLOR=#006600], [/COLOR][COLOR=#0000CC]103 1[/COLOR][COLOR=#006600]};[/COLOR][/COLOR]
int[] zahlen = {1 1, 4 2, 5 1, 99 2, 103 1};
int zufall = random.nextInt(zahlen.length);
int[][] zahlen = {{1, 1},{4, 2},{5, 1},{99, 2},{103, 1}};
System.out.println("Zwei Zufallszahlen: " + zahlen[zufall][0] + " " + zahlen[zufall][1]);
Perfekt, danke euch beiden.Das geht wahrscheinlich am besten mit einem zweidimensionalen Array:Code:int[][] zahlen = {{1, 1},{4, 2},{5, 1},{99, 2},{103, 1}}; System.out.println("Zwei Zufallszahlen: " + zahlen[zufall][0] + " " + zahlen[zufall][1]);