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 {

    boolean[] booleanArr = new boolean[10];
    boolean booleanFillValue = false;
    Arrays.fill(booleanArr, booleanFillValue);
  }
}

    //Filling Elements in an Array: byte type

    import java.util.Arrays;

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

    byte[] byteArr = new byte[10];
    byte byteFillValue = (byte) 0xFF;
    Arrays.fill(byteArr, byteFillValue);
  }
}

    //Filling Elements in an Array: char type

    import java.util.Arrays;

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

    char[] charArr = new char[10];
    char charFillValue = 'c';
    Arrays.fill(charArr, charFillValue);
  }
}

    //Filling Elements in an Array: short type

    import java.util.Arrays;

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

    short[] shortArr = new short[10];
    short shortFillValue = 2;
    Arrays.fill(shortArr, shortFillValue);
  }
}
    //Filling Elements in an Array: int type

    import java.util.Arrays;

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

    int[] intArr = new int[10];
    int intFillValue = -1;
    Arrays.fill(intArr, intFillValue);
  }
}
    //Filling Elements in an Array: long type

    import java.util.Arrays;

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

    long[] longArr = new long[10];
    long longFillValue = -1;
    Arrays.fill(longArr, longFillValue);
  }
}

    //Filling Elements in an Array: float type

    import java.util.Arrays;

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

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

    Arrays.fill(floatArr, floatFillValue);
  }
}

    //Filling Elements in an Array: double type

    import java.util.Arrays;

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

            double[] doubleArr = new double[10];
            double doubleFillValue = -1;
            Arrays.fill(doubleArr, doubleFillValue);
        }
    }