Paul Clapham wrote:Interestingly, it let me use Structured Concurrency classes without checking the "Enable Preview Features" box in the project's properties. Not even a warning. Although it might have been different if I'd tried running the compiled code outside Eclipse, I suppose.
Stephan van Hulst wrote:That would be a really bad idea.
In essence, that means that I can no longer control whether and how a caller makes an instance of my class, and it also means that I can create instances of classes without providing the bare minimum of information they need for initialization.
Consider the following example:
First of all, you're not supposed to instantiate an Integer directly. You're supposed to use a literal or one of the valueOf() factory methods. Secondly, if you DID instantiate an Integer directly, then what would it even mean to instantiate one without a value?
Remember, according to your proposal, Integer should inherit the parameterless constructor from the Number class.
Tim Holloway wrote:Java supports a "universal" file path notation which is essentially that of Unix. There are conversion rules that can map DOS paths to this notation and they necessarily include the drive ID. So "C:\Program Files\java" maps as "/C:/Program Files/java". Resolving in the other direction is ambgious, so expect that "/" will map to the root directory of the currently-logged drive.
Assuming you're not doing something stupid like uploading/creating/altering files within the WAR directory structure. Which will fail horribly on an unexploded WAR.
One final note. Java is a very bad language to use a "current directory" in. There's only one current directory for a given JVM instance, and since many processes may be running under that JVM, you can not be 100% sure that one of them might change the current directory programmatically at any given time. So as a rule, absolute paths are preferable, the Universal path notation is likewise preferable and ideally that path should include the currently-logged disk when running Windows.
Anil Philip wrote:
PS C:\> wsl
ANIL-PHILIP-LAPTOP:/mnt/c$ sudo mkdir /Try/tea/
ANIL-PHILIP-LAPTOP:/mnt/c$ sudo mkdir /Try/tea/earlgrey
ANIL-PHILIP-LAPTOP:/mnt/c$ sudo mkdir /Try/tea/hot.txt
I can see it did create the files
ANIL-PHILIP-LAPTOP:/mnt/c$ cd /Try/tea/earlgrey/.././hot.txt
ANIL-PHILIP-LAPTOP:/Try/tea/hot.txt$ cd ..
ANIL-PHILIP-LAPTOP:/Try/tea$ ls
earlgrey hot.txt
Kieu Thoai wrote:So what if I want it to print the word blocked first and then get the result?
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/util/Spliterator.html#trySplit() wrote:
If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.
If this Spliterator is ORDERED, the returned Spliterator must cover a strict prefix of the elements.
Unless this Spliterator covers an infinite number of elements, repeated calls to trySplit() must eventually return null.