1c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray/* 2c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 3c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * 4c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 5c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * you may not use this file except in compliance with the License. 6c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * You may obtain a copy of the License at 7c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * 8c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 9c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * 10c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 11c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 12c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * See the License for the specific language governing permissions and 14c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray * limitations under the License. 15c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray */ 16c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray 17c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffraypublic class Main { 18c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray private Object[] data; 19c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray private int size; 20c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray 21c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray public Main() { 22c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray data = new Object[4]; 23c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray size = 0; 24c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray } 25c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray 26c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray public void removeElementAt(int index) { 27c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray for (int i = index; i < size - 1; i++) { 28c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray data[i] = data[i + 1]; 29c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray } 30c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray data[--size] = null; 31c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray } 32c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray 33c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray public static void main(String[] args) { 34c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray Main main = new Main(); 35c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray main.size++; 36c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray main.removeElementAt(0); 37c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray if (main.size != 0) { 38c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray throw new Error("Unexpected size"); 39c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray } 40c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray } 41c8147a76ed2f440f38329dc08ff889d393b5c535Nicolas Geoffray} 42