Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class psx {
- public static void noexc(int n) {
- int[] a = new int[0];;
- for (int i : new Range(n)) {
- if (a.length > 0) {
- int fp = a[1];
- }
- }
- }
- public static void exc(int n) {
- int[] a = new int[0];
- for (int i : new Range(n)) {
- try {
- int fp = a[1];
- } catch (java.lang.ArrayIndexOutOfBoundsException e) {
- continue;
- }
- }
- }
- public static void main(String[] args) {
- int n = 128 * 1024 * 1024;
- if (args.length > 0) {
- noexc(n);
- } else {
- exc(n);
- }
- }
- }
- class Range implements Iterable<Integer> {
- private int limit;
- public Range(int limit) {
- this.limit = limit;
- }
- @Override
- public Iterator<Integer> iterator() {
- final int max = limit;
- return new Iterator<Integer>() {
- private int current = 0;
- @Override
- public boolean hasNext() {
- return current < max;
- }
- @Override
- public Integer next() {
- if (hasNext()) {
- return current++;
- } else {
- throw new NoSuchElementException("Range reached the end");
- }
- }
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Can't remove values from a Range");
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment