+ 2
I just started learnig java, and my first try with methods doesnt work, but i dont understand whats wrong, could sb. help ?
Java Problem
16 Respostas
+ 4
Jnn it is just that the static members were also given the privilege to be invoked without the object of the class.
We are all learning here so don't say sorry because it's completely fine to make mistakes.
+ 3
Jnn The static methods can be invoked using an object of the class as well, you seem to disagree with that in your 2nd point. Just letting you knowđ
+ 2
1) The entry point of your code is the public static void main(String[] args) function.
2) if you call a function without using an instance of a class it needs to be static (can be called by the class not the object of a class)
3) all attributes or functions called by a static function also need to be static
+ 2
4) In the function where you print hello world you don't need the String[] args parameter. Its only used in the main function to access parameters when running the code. But that is often not used.
+ 2
Avinesh
Im sry you are correct đ
+ 2
Now that the issue is resolved, maybe you need to prefix your question with [Solved].
+ 1
Could you post your code here?
+ 1
Okay thanks alot =)
What does this static before the string changes? Why doesent it work without it?
+ 1
Really thank you =)
+ 1
Because that is an attribute. If you have a class every object has its own. But you use this attribute in a static function only called by the class so this attribute needs to be static too
+ 1
Mirielleđ¶
Not all methods need to be static if you create an instance of this class in the main method you can call non static methods with this instance
+ 1
Practice in Android studio software which is only one best option for java.