Java: Difference between revisions
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 5: | Line 5: | ||
==Usage== | ==Usage== | ||
===Installation=== | |||
I recommend downloading an IDE such as [https://www.jetbrains.com/idea/ Intellij IDEA]. | |||
====Linux==== | |||
I recommend using OpenJDK.<br> | |||
[https://openjdk.java.net/install/ Link] | |||
==Features== | ==Features== | ||
| Line 12: | Line 16: | ||
[https://stackoverflow.com/questions/28329419/when-does-a-local-string-scanner-get-garbage-collected StackOverflow Reference]<br> | [https://stackoverflow.com/questions/28329419/when-does-a-local-string-scanner-get-garbage-collected StackOverflow Reference]<br> | ||
[https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html AutoCloseable Java 8]<br> | [https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html AutoCloseable Java 8]<br> | ||
Since Java does not have destructors and thus no RAII objects, you will need to close | Since Java does not have destructors and thus no RAII objects, you will need to close any resources you open manually.<br> | ||
One way to automate this is to use autocloseable classes introduced in Java 7.<br> | One way to automate this is to use autocloseable classes introduced in Java 7.<br> | ||
These classes, which implement that AutoCloseable interface, can be wrapped in a try block | These classes, which implement that AutoCloseable interface, can be wrapped in a try block | ||
| Line 23: | Line 27: | ||
} // close will be implicitly called | } // close will be implicitly called | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Programming languages]] | |||