title: Java - Using TryCatch outside a method
body: <pre><code>import org.newdawn.slick.Image;
  import org.newdawn.slick.SlickException;
  
  public class Images {
      try {
          public static Image button = new Image("images/buttons/0/Button.png");
      } catch(SlickException e) {
      e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>This just gives an error, I want to be able to store some images in static variables and access them from another class without instantiating it.</p>
  
  <p>I could possibly make a method to initialise all them and set values to them, but then the variables wouldn't be static.</p>
  
  <p>The reason I need TryCatch is because the constructor of the <code>Image</code> class throws a <code>SlickException</code></p>