title: Try With Resources vs Try-Catch
body: <p>I have been looking at code and I have seen try with resources. I have used the standard try-catch statement before and it looks like they do the same thing. So my question is <strong>Try With Resources vs Try-Catch</strong>  what are the differences between those, and which is better.</p>
  
  <p>Here is a try with resources :</p>
  
  <pre><code>objects jar = new objects("brand");
  objects can= new objects("brand");
  
  try (FileOutputStream outStream = new FileOutputStream("people.bin")){
      ObjectOutputStream stream = new ObjectOutputStream(outStream);
  
      stream.writeObject(jar);
      stream.writeObject(can);
  
      stream.close();
  } catch(FileNotFoundException e) {
      System.out.println("sorry it didn't work out");
  } catch(IOException f) {
      System.out.println("sorry it didn't work out");
  }
  </code></pre>