I want to make a program, which moves every entry by +1 for every new entry.
e.g
myArray[0]= Thomas
and after another entry it becomes:
myArray[0] = Fred
myArray[1] = Thomas
.
after 5 entries it becomes .
myArray[4]=Thomas;
import java.util.Scanner;
import java.util.Arrays;
public class UB5{
    static String input(String name){
        Scanner user_input = new Scanner(System.in);
            System.out.println("Enter your name: ");
            name = user_input.nextLine();
            return name;
        }
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String myArray[] = new String[5];
        myArray[0] = "";
        myArray[1] = null;
        myArray[2] = null;
        myArray[3] = null;
        myArray[4] = null;
        String s = "";
        String temp = myArray[0];
        myArray[0] = myArray[1];
        myArray[1] = temp;
        for(int i = 0; i < myArray.length; i++){
            myArray[i] = input(s);
            if(myArray[i] == null){               
                myArray[i] = myArray[i+1];
            }
        }
        System.out.println(Arrays.toString(myArray));
    }
}
The unwanted output that I get:
Enter your name:
Thomas
Enter your name:
Peter
Enter your name:
Fred
Enter your name:
Bruce
Enter your name:
Angelo
[Thomas, Peter, Fred, Bruce, Angelo]
 
     
    