X
X
xllnc2019-08-10 15:16:36
Programming languages
xllnc, 2019-08-10 15:16:36

Why can functions be outside classes in some languages ​​and not in others?

For example, now I just started to study Kotlin, and I see that functions can exist on their own, but in Java, I know, there are functions only inside classes. Is it just a feature of the language? Or is it related to something? Why is it so in some and so in others? That is, is it worth using such functions that are outside the classes, or is it better to define them inside?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2019-08-10
@Blackeyed7

There are no functions in Java at all, only methods. Methods, by definition, cannot be outside classes. And this is done because Java was designed as a language forcing people to write in OOP.

M
Maxim Timofeev, 2017-12-25
@rafamont

Apparently you need to know css. I can’t even imagine what the difficulties arose here?
Shading is probably easier with border-image or pseudo-elements like :after
Photos with border-radius: 50%
italic gray text. What specifically is causing you difficulty?
For if you expect someone to do it for you - it's not accepted here, although there is a chance to get on an unemployed altruist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question