Write a java program to split an array in a specific position

Write a java program to split an array in a specific position. Splitting an array from a specific location with a Java program. Enter the array’s size, followed by all of the array’s elements. Now type in the location where you want to divide from. The elements from the first position are copied to the second array, and the remaining elements are copied to the third array. the Java source code for Splitting an Array from a Specific Position

import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
int n, x, flag = 1, local = 0, k = 0,j = 0;
Scanner s = new Scanner(System.in);
System.out.print("Enter the number of elements you want in array");
n = s.nextInt();
int a[] = new int[n];
int b[] = new int[n];
int c[] = new int[n];
System.out.println("Enter all the elements");
for (int i = 0; i < n; i++)
{
a[i] = s.nextInt();
}
System.out.print("Enter the position from where you want to split");
local = s.nextInt();
for(int i = 0; i < local; i++)
{
b[k] = a[i];
k++;
}
for(int i = local; i < n; i++)
{
c[j] = a[i];
j++;
}
System.out.print("First array");
for(int i = 0;i < k; i++)
{
System.out.print(b[i]+" ");
}
System.out.println("");
System.out.print("Second array");
for(int i = 0; i < j; i++)
{
System.out.print(c[i]+" ");
}
}
}

Enter the number of elements you want in array 5
Enter all the elements
34
56
678
23
12
Enter the position from where you want to split 678

First array 34 56

Second array 23 12