Questions tagged [modifier]

347 questions
475
votes
8 answers

What does the "static" modifier after "import" mean?

When used like this: import static com.showboy.Myclass; public class Anotherclass{} what's the difference between import static com.showboy.Myclass and import com.showboy.Myclass?
JSON
  • 5,131
  • 4
  • 20
  • 15
391
votes
5 answers

What is the 'open' keyword in Swift?

The ObjectiveC.swift file from the standard library contains the following few lines of code around line 228: extension NSObject : Equatable, Hashable { /// ... open var hashValue: Int { return hash } } What does open var mean in this…
Clashsoft
  • 11,553
  • 5
  • 40
  • 79
282
votes
20 answers

SwiftUI - How do I change the background color of a View?

I'm beginning to try out SwiftUI and I'm surprised that it doesn't seem to be straightforward to change the background color of a View. How do you do this using SwiftUI?
jeremyabannister
  • 3,796
  • 3
  • 16
  • 25
134
votes
4 answers

What are Transient and Volatile Modifiers?

Can someone explain what the transient and volatile modifiers mean in Java?
Vijay Bhaskar Semwal
  • 1,525
  • 3
  • 12
  • 8
84
votes
7 answers

Difference between static modifier and static block

Someone explain to me the differences between the following two statements? A static final variable initialized by a static code block: private static final String foo; static { foo = "foo"; } A static final variable initialized by an…
Fabio_M
  • 879
  • 7
  • 21
81
votes
12 answers

Can you alter a Javascript function after declaring it?

Let's say I have var a = function() { return 1; }. Is it possible to alter a so that a() returns 2? Perhaps by editing a property of the a object, since every function is an object? Update: Wow, thanks for all the responses. However, I'm afraid I…
pr1001
  • 21,727
  • 17
  • 79
  • 125
78
votes
4 answers

How does extern work in C#?

Whenever I look deeply enough into reflector I bump into extern methods with no source. I read the msdn documentation at http://msdn.microsoft.com/en-us/library/e59b22c5(v=vs.80).aspx. What I got from that article is that methods with the extern…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
75
votes
8 answers

Pros and cons of package private classes in Java?

I am learning Java recently, and I came across the notion of package-private classes, which is the default if we don't specify anything. But then I realized: I seldom see the use of package-private class. Is there a reason for this, e.g., it has…
zw324
  • 26,764
  • 16
  • 85
  • 118
46
votes
5 answers

isAbstract() Modifier returning Incorrect result - Why?

To my understanding the following code should print False as output However, when I ran this code it is printing True as output. From Java docs: Return true if the integer argument includes the abstract modifier, false otherwise. public class…
T-Bag
  • 10,916
  • 3
  • 54
  • 118
34
votes
4 answers

What is the point of "static new" modifier for a function?

Today, I found something in legacy code. It has "static new" for one function. It looks like this. class Foo { public static void Do() { Console.WriteLine("Foo.Do"); } } class Bar: Foo { public static new void Do() { …
Morgan Cheng
  • 73,950
  • 66
  • 171
  • 230
34
votes
3 answers

Perl Regex 'e' (eval) modifier with s///

I'm having a little trouble comprehending this simple use of the /e regex modifier. my $var = 'testing'; $_ = 'In this string we are $var the "e" modifier.'; s/(\$\w+)/$1/ee; print; Returns: "In this string we are testing the "e" modifier." I…
pb149
  • 2,298
  • 1
  • 22
  • 30
33
votes
5 answers

Jetpack Compose - Order of Modifiers

Documentation says that Modifiers are applied from the left. But from this example it looks like they are applied from the right: First border and then padding because there is no space between text and border Text("Hi there!",…
20
votes
4 answers

How can I add flags to an existing regular expression?

I have a bunch of regular expression, e.g. /[a-z]/. Later in my program I need to have this as /[a-z]/g, so I need to add the 'global' modifier later. How can I add a modifier to an existing regular expression?
Jinu Joseph Daniel
  • 5,864
  • 15
  • 60
  • 90
20
votes
3 answers

Difference between regular expression modifiers (or flags) 'm' and 's'?

I often forget about the regular expression modifiers m and s and their differences. What is a good way to remember them? As I understand them, they are: 'm' is for multiline, so that ^ and $ will match beginning of string and end of string…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
20
votes
8 answers

Why subclass in another package cannot access a protected method?

I have two classes in two different packages: package package1; public class Class1 { public void tryMePublic() { } protected void tryMeProtected() { } } package package2; import package1.Class1; public class Class2 extends…
user2986848
  • 217
  • 1
  • 2
  • 3
1
2 3
23 24