What is static in Java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is static in Java?

use of static

8th May 2017, 2:41 PM
Champs
5 Answers
+ 20
IDK What are you asking about? As there's a static class, variable and keyword! Static Class: A static class or created inside a class is called static nested class in java. It cannot access non-static data members and methods. It can be accessed by outer class name. It can access static data members of outer class including private. Static variable: It is a variable which belongs to the class and not to object(instance). Static variables are initialized only once , at the start of the execution. static block: Static block is mostly used for changing the default values of static variables.This block gets executed when the class is loaded in the memory. A class can have multiple Static blocks, which will execute in the same sequence in which they have been written into the program.
8th May 2017, 2:45 PM
Dev
Dev - avatar
+ 10
@Pawan Maurya I like java. Unfortunately the challenges are only on the core java
12th May 2017, 6:19 AM
Alexey
Alexey - avatar
+ 9
In short, these are the elements that are executed before any instance of the class is created. I recommend reading the documentation on this, this is an extensive question
8th May 2017, 2:48 PM
Alexey
Alexey - avatar
+ 2
you play very well đŸ˜”
12th May 2017, 6:08 AM
P∆WAN M∆URY∆
P∆WAN M∆URY∆ - avatar
+ 1
I'm asking y do v use static?
8th May 2017, 2:50 PM
Champs