Take the 2-minute tour ×

Possible Duplicate:
“using” keyword in java

I have one problem, In c# "using " is keyword but how to use in java

using (layout xmds = new layout()){
share|improve this question
what really you want to do ??? –  Prasad Jan 9 '13 at 12:00
seems to be java 7 try with resources –  Subhrajyoti Majumder Jan 9 '13 at 12:02
add comment

marked as duplicate by BoltClock Jan 9 '13 at 15:04


1 Answer

In Java 7, all classes implementing AutoCloseable can be used with the "try-with-resources" construct:

class Layout implements AutoCloseable { ... }

// Usage
try (Layout layout = new Layout()) {
    // do stuff here

Edit: Noticed you tagged the question with "android". Android doesn't support Java 7, so you won't be able to use try-with-resources there.

share|improve this answer
add comment
