The code is compiled but gives errors (
package com.company; public class BoolVector { int size; // размер вектора int[] arr = new int[size]; // элементы вектора BoolVector(int size) { for(int i=0;i<size;i++) { System.out.print("Введите число"); arr[i]=10; } } } public class Main { public static void main(String[] args) { BoolVector A = new BoolVector(2); for (int i = 0; i < A.size; i++) { System.out.print(A.arr[i]); } return; } } Here is what the compiler produces:
Insert the number
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.company.BoolVector. (BoolVector.java:15)
at com.company.Main.main (Main.java:10)