Advertisement
Guest User

brute force to find maximum length of a vect

a guest
Nov 27th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.34 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. public class VMaxLength {
  5.   public static void main(String[] args) {
  6.     boolean error = false;
  7.     int max = 0;
  8.  
  9.     while (!error) {
  10.       max++;
  11.       try {
  12.     int[] x = new int[max];
  13.       } catch (OutOfMemoryError e) {
  14.     error = true;
  15.       }
  16.     }
  17.  
  18.     System.out.println(max);
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement