Frank Mi

Ranch Foreman
+ Follow
since Aug 19, 2020
Cows and Likes
Cows
Total received
8
In last 30 days
5
Total given
0
Likes
Total received
23
Received in last 30 days
16
Total given
24
Given in last 30 days
22
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Frank Mi

Md Zuanyeed Kamal wrote:However, if we have regular expression on only one side "[a-z].*" , or ".*[a-z]" , then what would it mean in general ? or how would you explain that ?



"[a-z].*" : starts with a lower case letter (whatever after the first character doesn't matter)
".*[a-z]" : ends with a lower case letter (whatever before the last character doesn't matter)
".*[a-z].*" : contains a lower case letter (a string has a lower case letter in the middle, whatever before or after it doesn't matter)
14 hours ago
In regular expression, .* matches any string sequences (in a same line of course). When you have .* on both side, that means the string can start and end with anything before and after [a-z]. That is to say, if a string has [a-z] in it, no matter what other characters before and after it, the regular expression matches.

So:
".*[a-z].*" matches if: the string CONTAINS (at least one) lower case letter.
".*[A-Z].*" matches if: the string CONTAINS (at least one) upper case letter.
".*[0-9].*" matches if: the string CONTAINS (at least one) number.
"[a-zA-Z0-9]*" matches: all characters in the string are letters and numbers.
1 day ago
I just recalled another one, how do you pronounce "ArrayDeque"? Most of the time, I heard "Array Deck", but sometimes I also heard "Array Dee Queue". Somebody would argue that "Array Deck" doesn't sound like a queue.
1 day ago
It's very interesting that, though I still don't know how to pronounce "varargs", I learned how to pronounce "Gloucester" here.  
3 days ago
Great answer! It's very clear, thank you, Stephan! I will try it later.
3 days ago
It makes sense. This format is good enough. Thank you.

3 days ago
Sorry, I didn't make my question clear. My question is actually why doesn't it take unlimited numbers of key-value pairs like varargs.
3 days ago
Why Map.of() method takes up to 10 value pairs as input parameter?
3 days ago
Why the keySet() method of HashMap returns a Set<K> rather than a HashSet<K>? And why the values() method returns a Collection<V> rather than a more concrete type?
3 days ago
Do you pronounce it as two separate words like "var  args"? Or do you pronounce it as a single word, say, something like "vəˈrɑːrgs"?
3 days ago

Stephan van Hulst wrote:Types that implement Constable can express their values as a ConstantDesc. In short, if a class implements Constable, you can store its values in the JVM's constant pool and you can compile symbolic references to these constants into the class file. I suppose the purpose of all of this is that it allows Java to use compiled constants of types other than primitives and strings.



Does it mean, in this way, I can define my own constant variable types? Say, I can use my own class type in switch case expression?
3 days ago
Welcome to the Ranch.  

The difference is because your last print statement uses the print() method instead of the println() method.

System.out.println("") prints a new line, while System.out.print("") prints nothing.
4 days ago
I found that, from Java 12, Integer and other number classes also implement the Constable and ConstantDesc interface. What are they used for? How do they affect our programming?
4 days ago