0

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()){
}
Community
  • 1
  • 1
Karthikeyan Karthik
  • 114
  • 1
  • 2
  • 14

1 Answers1

2

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.

gustafc
  • 28,465
  • 7
  • 73
  • 99