Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java equivalent to #region in C#

I want to use regions for code folding in Eclipse; how can that be done in Java?

An example usage in C#:

#region name //code #endregion 
like image 675
Pentium10 Avatar asked Feb 26 '10 20:02

Pentium10


People also ask

Is there a Java equivalent to with?

try-with-resources is its Java equivalent, and is available in Java 7 and up. This is the try-with-resources construct.

Is C# equivalent to Java?

Java and C# are incredibly similar. Both languages are somewhat derived from C++ and from similar first principles. Java was developed in 1995 to create a language with a simpler programming model than C++ while still preserving some of the same syntax of the language to facilitate developers transitioning to it.

Is there a === in Java?

There is no === operator for comparison. When you want to compare two references, you should check - 1. If they are pointing to same object.

IS NULL operator in Java?

It is considered a concatenation in java. Here, the null will only be concatenated with the String variable. If we use “+” operator with null and any other type(Integer, Double, etc.,) other than String, it will throw an error message.


2 Answers

Jet Brains IDEA has this feature. You can use hotkey surround with for that (ctrl + alt + T). It's just IDEA feature.

Regions there look like this:

//region Description  Some code  //endregion 
like image 157
Alexander Bezrodniy Avatar answered Sep 24 '22 00:09

Alexander Bezrodniy


There's no such standard equivalent. Some IDEs - Intellij, for instance, or Eclipse - can fold depending on the code types involved (constructors, imports etc.), but there's nothing quite like #region.

like image 43
Brian Agnew Avatar answered Sep 22 '22 00:09

Brian Agnew