How to add new elements to an array?

后端 未结 18 1925
误落风尘
误落风尘 2020-11-22 04:55

I have the following code:

String[] where;
where.append(ContactsContract.Contacts.HAS_PHONE_NUMBER + \"=1\");
where.append(ContactsContract.Contacts.IN_VISIB         


        
18条回答
  •  天涯浪人
    2020-11-22 05:34

    It's also possible to pre-allocate large enough memory size. Here is a simple stack implementation: the program is supposed to output 3 and 5.

    class Stk {
        static public final int STKSIZ = 256;
        public int[] info = new int[STKSIZ];
        public int sp = 0; // stack pointer
        public void push(int value) {
            info[sp++] = value;
        }
    }
    class App {
        public static void main(String[] args) {
            Stk stk = new Stk();
            stk.push(3);
            stk.push(5);
            System.out.println(stk.info[0]);
            System.out.println(stk.info[1]);
        }
    }
    

提交回复
热议问题