Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the naming convention 'of' mean in Java?

Tags:

java

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"?

like image 371
Jimmy Guo Avatar asked Jan 15 '18 02:01

Jimmy Guo


People also ask

What are naming conventions in Java?

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.

What is .of method Java?

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.

What is the meaning of naming convention?

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.


Video Answer


1 Answers

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."

like image 127
Chris Martin Avatar answered Oct 02 '22 15:10

Chris Martin