Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {
    int startIndex = 0;
    int endIndex = 4;

    boolean[] booleanArr = new boolean[10];
    boolean booleanFillValue = true;

    Arrays.fill(booleanArr, startIndex, endIndex, booleanFillValue);

  }
}

    //Fill to a contiguous range of elements in an array: byte array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    byte[] byteArr = new byte[10];
    byte byteFillValue = 1;

    Arrays.fill(byteArr, startIndex, endIndex, byteFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: char array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    char[] charArr = new char[10];
    char charFillValue = 1;

    Arrays.fill(charArr, startIndex, endIndex, charFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: short array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    short[] shortArr = new short[10];
    short shortFillValue = 1;

    Arrays.fill(shortArr, startIndex, endIndex, shortFillValue);

  }
}

    //Fill to a contiguous range of elements in an array: int array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    int[] intArr = new int[10];
    int intFillValue = 1;

    Arrays.fill(intArr, startIndex, endIndex, intFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: long array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    long[] longArr = new long[10];
    long longFillValue = 1;

    Arrays.fill(longArr, startIndex, endIndex, longFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: float array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;

    float[] floatArr = new float[10];
    float floatFillValue = 1;

    Arrays.fill(floatArr, startIndex, endIndex, floatFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: double array

    import java.util.Arrays;

public class Main {
  public static void main(String[] argv) throws Exception {

    int startIndex = 0;
    int endIndex = 4;
    double[] doubleArr = new double[10];
    double doubleFillValue = 1;
    Arrays.fill(doubleArr, startIndex, endIndex, doubleFillValue);
  }
}

    //Fill to a contiguous range of elements in an array: String array

    import java.util.Arrays;

    public class Main {
        public static void main(String[] argv) throws Exception {

            int startIndex = 0;
            int endIndex = 4;

            String[] stringArr = new String[10];
            String stringFillValue = "1";

            Arrays.fill(stringArr, startIndex, endIndex, stringFillValue);

        }
    }