Join us, let's discuss Web3, crypto and blockchain technology.

Class Methods

Class methods, like class variables, apply to the class as a whole and not to its instances. Class methods are commonly used for general utility methods that may not operate directly on an instance of that class, but fit with that class conceptually. For example, the String class contains a class method called valueOf(), which can take one of many different types of arguments (integers, booleans, other objects, and so on). The valueOf() method then returns a new instance of String containing the string value of the argument it was given. This method doesn’t operate directly on an existing instance of String, but getting a string from another object or data type is definitely a String-like operation, and it makes sense to define it in the String class.



dp

Read next...

Mountains
Hivefirm
Hivefirm is a future focused community for all things Web 3 and crypto-related content

Follow us

Discover more of what matters to you