+ 3

What is the purpose of (static) and (void) in java

guys I'm new to java so please explain it to me

25th Jan 2017, 1:35 PM
Darshana Herath
Darshana Herath - avatar
6 odpowiedzi
+ 6
The module explains it really well, but basically static means that it belongs to the class, not to a specific object, and void means that it does not return any value. Read through the lesson a few more times and you will understand it better.
25th Jan 2017, 1:55 PM
Nikolay Ganev
Nikolay Ganev - avatar
0
I don't know about static but void returns a value pack
29th Jan 2017, 12:22 PM
Pradyumna Joshi
Pradyumna Joshi - avatar
0
If "void" is not mentioned then the value/string which has to be obtained as the output will not return any value!!!! So "void" is Required!!!
1st Feb 2017, 4:33 PM
Milind Anarkat
Milind Anarkat - avatar
0
static is the primary keyword reserved which is read by the compiler before reading any other statement. it is executed before any other function present in the program
2nd Feb 2017, 12:58 PM
Mohit Kala
Mohit Kala - avatar
0
static is a key word. if a function is preceded by static key word, it can be called or accessed before any of the objects have been created. here objects correspond to the instances of the class to which the above said function belongs. as far as void is concerned a function preceded by void key word does not return any sort of value to the calling module or OS (in case of main).
4th Feb 2017, 1:22 PM
Showkat Ahmad
Showkat Ahmad - avatar
0
static keyword before a method , means that we doesn't need to create an object of a class to call that static method.Example : main() method we doesn't need to create an object to call main within a program. Therefore static methods can be called by only static data members/member functions( A non static data member cannot call a static member functions) also if a data member is said to be a static initialise with 0 then that data member can access a static member function "n" number of times, every n++ will share a common memory area, no separate memory is created for each call. Whereas in non static member we have a separate memory allocation for every call. and void signifies that a function doesn't return anything, return type is mandatory.Also main can have different return types depending upon the content in it!
14th Feb 2017, 6:31 PM
Astha Bhasin
Astha Bhasin - avatar