+ 1

What is static class?

Can anybody explain static class in java? What is the purpose of static class ? Thanks in advance

25th Aug 2018, 2:13 PM
Sbk0103
Sbk0103 - avatar
2 odpowiedzi
0
Am asking about static class not static variable or method
25th Aug 2018, 2:17 PM
Sbk0103
Sbk0103 - avatar
0
There is probably some abuse of terminology too - sometimes when we talk about static classes we mean utility classes that only have static methods. This allows us to use these methods from anywhere without creating an object instance. Of course, in the 'proper' sense, a static class is a class that is declared static... which means it belongs to another class. Apart from some encapsulation benefits, it's basically another type (the same as declaring a new class in it's own file) An example of when you might use it is with the builder pattern, you'd have a builder as an inner static class, as you won't need the builder class elsewhere so it's good for grouping things together logically
25th Aug 2018, 3:00 PM
Dan Walker
Dan Walker - avatar