# 5.8) Can a try block be followed only by a finally block?

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-La_AIPjAJNtqYinJwFk%2F-La_AK9qlCwN9t5REHTl%2Fimage.png?alt=media\&token=845a0ec8-3eca-49f3-868d-a691ba1e8216)

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-La_AIPjAJNtqYinJwFk%2F-La_ASbL4L0e_CYJqfl9%2Fimage.png?alt=media\&token=eb2d74a1-02a7-4084-8217-a24d7600f56d)

```java
public class NoCatchOnlyFinally {
	public static void main(String[] args) {
		String name = null;
		try {
			System.out.println("Try block : open resource 1");
			System.out.println("Try block : open resource 2");
			System.out.println("in try :" + name.length());
			System.out.println("Try block : close resources");
		} finally {
			System.out.println("finally : close resources");
		}
	}
}
```

#### Output:

![](https://2172743581-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-La4k4liN--SZ6ay4iod%2F-La_AIPjAJNtqYinJwFk%2F-La_CgNPLJn3iYDVXW1p%2Fimage.png?alt=media\&token=588acd52-254b-4cd1-8152-73c42bcd8c5b)
