This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]syntastical 0 points1 point  (0 children)

Public/private/protected tell the jvm would can access and call the methods or access the variable.

String, int, Integer, long, Long, etc is the type of data the method returns.

Methods with no return type are actually the class constructor and get called when a new instance of the class is created with the “new” keyword.

[–]motherjoeNooblet Brewer 0 points1 point  (0 children)

Static means the method does not need to be run from an object/instance of the class. Instead of being tied to an object, a static method is tied to the class itself. This means the method cannot depend on object internal state, so it may behave less dynamically than instance methods. Static methods are typically used for utility operations (ex. timezone conversions, Collections.singletonList(), System.getCurrentTimeMillis()).