while creating pattern objects like
Pattern pattern1 = Pattern.compile("s", Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
what is the logic behind passing multiple flags within a same parameter Pattern.CASE_INSENSITIVE | Pattern.DOTALL ?
Is there any name for this kind of declaration?
Can objects of any type be passed like this?
No, objects cannot be passed like that.
This way is typically used to pass a variable amount of flags (true/false) to a method. The constant names are defined as int or long.
For example:
The values of the int constants are multiples of 2 so they can be combined with an logical or.
For example:
myValue contains now the information of FLAG_A and FLAG_C. To check if FLAG_A is set you can use: