Statická inštancia vs

Príklady kódu

1
0

Statická metóda vs metóda inštancie

static or class method
1) A method that is declared as static is known as the static method
2) We don't need to create the objects to call the static methods
3) Non-static (instance) members cannot be accessed in static context 
(static method, static block and static nested class) directly.
4) For example: public static int cube(int n){
return n*n*n*; (multiply *) }

Instance method
1) A method that is not declared as static is known as the instance method.
2) The object is required to call the instance method.
3) Static and non-static variables both can be accessed in instance methods.
4) For example: public void msg() {
...}.
0
0

Statická inštancia vs

Static vs Instance
Static Belong to Class and it has one copy
Static methods only accept static members

Instance Belongs to the object
You can have multiple copies of instance variables


for example webdriver should be static since
we need one copy of webdriver.

Podobné stránky

Podobné stránky s príkladmi

V iných jazykoch

Táto stránka je v iných jazykoch

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................