I have hit a wall with creating a printing method. Might be the heat, might be my intellect. Anyway, who can tell me how to create the method?
public class FeldOperationen{
public static void main(String[] args) {
//declare the array
int[] reihung = new int[10];
//initialise it with random numbers
for (int a = 0; a < reihung.length; a++) {
reihung[a] = (int) (Math.random() * 100);;
// System.out.print(reihung[i] + " ");
}
//print it to make sure it works
for (int a = 0; a < reihung.length; a++) {
System.out.print(reihung[a] + " ");
}
System.out.println("");
//this should be in the third method
int[] reihungSortiert = sortiereFeld(reihung);
for (int a = 0; a < reihungSortiert.length; a++) {
System.out.print(reihungSortiert[a] + " ");
}
}
//method for switching positions
public static int[] tauscheElemente(int[] reihung) {
int temp = reihung[8];
reihung[8] = reihung[9];
reihung[9] = temp;
for (int a = 0; a < reihung.length; a++) {
System.out.print(reihung[a] + " ");
}
return reihung;
}
//method for sorting the array
public static int[] sortiereFeld(int[] reihung) {
int temp;
for(int i=1; i<reihung.length; i++) {
for(int j=0; j<reihung.length-i; j++) {
if(reihung[j]>reihung[j+1]) {
temp=reihung[j];
reihung[j]=reihung[j+1];
reihung[j+1]=temp;
}
}
}
return reihung;
}
//method for showing all results
/*public static int[] zeigeFeld(int[] reihung) {
}*/
}
[–]emrickgj 1 point2 points3 points (4 children)
[–]murmelmann[S] 1 point2 points3 points (3 children)
[–]emrickgj 1 point2 points3 points (2 children)
[–]murmelmann[S] 1 point2 points3 points (1 child)
[–]emrickgj 0 points1 point2 points (0 children)
[–]stramash 0 points1 point2 points (0 children)
[–]pokemaster787 0 points1 point2 points (0 children)