As we can see in Java 8, there are many methods named 'of', like Stream.of()
, Optional.of()
, and many libraries like actorOf
in Akka.
What does this "of" mean? Is it the English word "of" or an abbreviation for something like "Object Factory"?
For variables, the Java naming convention is to always start with a lowercase letter and then capitalize the first letter of every subsequent word. Variables in Java are not allowed to contain white space, so variables made from compound words are to be written with a lower camel case syntax.
The of() method of java. util. Optional class in Java is used to get an instance of this Optional class with the specified value of the specified type. Syntax: public static <T> Optional<T> of(T value) Parameters: This method accepts value as parameter of type T to create an Optional instance with this value.
A naming convention is a convention (generally agreed scheme) for naming things. Conventions differ in their intents, which may include to: Allow useful information to be deduced from the names based on regularities.
It is an English word, yes. It is usually chosen so that the expression will read like an English phrase. For example, Stream.of(3, 4)
is supposed to look like "stream of three and four," which is sort of like a shortened version of "a stream that is made of the numbers three and four."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With