Java Constructor variables being ignored

前端 未结 7 1132
我在风中等你
我在风中等你 2021-01-27 05:54

I am trying to create a instance of the object Iset. When the person makes the object they have to give an int which will be the size of a boolean array that will store a set of

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-27 06:18

    You should use the this keyword, an make the constructor public if you want to instantiate it in another class:

    public class ISet {
        public int size;
        boolean[] iSet;
    
    
        public ISet(int a) {
            this.size = a;
            this.iSet = new boolean[a];
        }
    

提交回复
热议问题