+ 1
Are the keywords 'class', 'public static avoid' and all those compulsory in writing Java?
class MyClass { public static void main(String[ ] args) { System.out.println("I am learning Java"); } }
3 Respostas
+ 2
Philosophical Coder These are not compulsory but neccessary while writing java code.
Let's look at real life example :
If you don't have a name how others call you .
If you don't have a house how you live .
yes , class keyword is for recognize the class and access specifiers like ..public, private and protected for define that scope .
+ 1
1. Yes if you wanna make these methods accessible from other classes or outside class, then you need to use public otherwise they are private by default.
2. If you wanna call a method or attribute of class without creating its instance then you need to use static.
3.void means it returns no data otherwise the compiler will give an error .
4.class acts as a blueprint for your objects , they all are able to access same attributes and methods of class without having to create the same method and attribute for each of them.
I will advice to do some search about these 4 words .