After @staticmethod decoration, the methods in the class are converted to static methods
1 class A: 2 3 @staticmethod 4 def B (self): 5 Print ('')
A static method cannot access an instance variable or a class variable, which
In C + +, a static member is an entire class rather than an object, and a static member variable stores only one copy for all objects to be shared. So it can be shared across all objects. Using static member variables to implement data sharing
1, jquery plug-in type:1), the plug-in that encapsulates the object method (equivalent to an instance method) (using $.fn.extend ({"Method name": function (parameter) {//Method body}}))2), the plug-in that encapsulates the global function
How to use PHP static methods and attributes. As we all know, the goal of OOP is to write code once, copy, copy, inherit, inherit, and then inherit to make reasonable use of every job, and also facilitate code management. As we all know, the goal of
The advantage of a static method is that it can be called directly without generating an instance of the class.The member that is decorated by the static method no longer belongs to an object, but to the class in which it resides. It needs to be
Precautions:1. Static code blocks cannot write this or object, because static blocks of code are executed before the object is initialized;2. Static code blocks are executed before code blocks are constructed;3. Static code blocks are used to
name; } Public Function GetName () { $this->echoname () }}} class newclass{ private $name = "Newclass"; Public Function Echoname () { echo $this->name; } Public Function test () { myclass::getname ();
The InetAddress class is the class used to describe IP addresses in Java. It is in the java.net package. In Java, the Inet4Address and Inet6Address classes are used to describe IPv4 and IPv6 addresses. Both classes are subclasses of InetAddress.
Static methods in a PHP class cannot inherit the public-decorated properties of other classes.
How can a static method in a PHP class not inherit the public-decorated properties of another class? such as the par.class.php and st.class.php codes are
2018-1-11 20:25:48 ThursdayScene:Previously wanted to chain call must first new an object, and then $obj->aa ()->bb () ...Now the static method of PHP7 (php7.0.13 php7.2 test pass) can also be chained to call theWriting:A::aa ():: BB ():: CC
This article illustrates several common considerations for using static methods in PHP. Share to everyone for your reference. The specific methods are as follows:
1. Even if the method in the class is not declared with static, but it is not used to
static method @statitmetodOnly nominal collation management, in fact, no property in the class or instance can be accessed in a static methodClass Method @classmethedOnly class variables can be accessed and instance variables cannot be
ImportOS#Os.system ()#Os.mkdir ()classDog (object):#name = ' KK ' def __init__(self,name): Self.name=name#@staticmethod #静态方法, it's really nothing to do with the class, and it's not going to take the self argument. #@classmethod #类方法, the self
Static methods
The static method is defined by @staticmethod, but the properties in the class and instance are not accessible in the static method, but the static method requires the class to invoke the#-*-Coding:utf-8-*-__author__ = "MuT6 Sch01
(1) Ext.define alias and alternate nameExt.onready (function () {ext.define (' User ', {config:{name: ' Zhang San ', age:23},//using aliases alias: ' Alias_user ',// Use alternate name alternateclassname: ' Alternateclassname_user ',
The class to be invoked
Package SS;
public class with {public
static Integer demo (String s) {
System.err.println s+
The class that executes the call
public class Ceshi {public
static void Main (string[] args) {
try
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.