It’s three completely different things:
public
means that the method is visible and can be called from other objects of other types. Other alternatives are private
, protected
, package
and package-private
. See here for more details.
static
means that the method is associated with the class, not a specific instance (object) of that class. This means that you can call a static method without creating an object of the class.
void
means that the method has no return value. If the method returned an int
you would write int
instead of void
.
The combination of all three of these is most commonly seen on the main
method which most tutorials will include.
Related Posts:
- Is Java “pass-by-reference” or “pass-by-value”?
- Is Java “pass-by-reference” or “pass-by-value”?
- Does Java support default parameter values?
- Does Java support default parameter values?
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- Usage of @see in JavaDoc?
- What does .class mean in Java?
- java, get set methods
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- Why nextLine() and not nextString() ?
- When is the finalize() method called in Java?
- Error: Main method not found in class Calculate, please define the main method as: public static void main(String[] args) [duplicate]
- How to return a boolean method in java?
- fixing errors on a program to call methods in java
- Python-like list comprehension in Java
- Java methods getting euclidean distance
- How can i fix this equals on primitive type(int)
- Return outside method error
- Class Declarations for temperature program in Java
- How to format strings in Java
- What exactly is Apache Camel?
- What is an instance variable in Java?
- How does the Java ‘for each’ loop work?
- Difference between StringBuilder and StringBuffer
- bad operand types for binary operator “&” java
- How can I use pointers in Java?
- How do I generate random integers within a specific range in Java?
- “Exception in thread “main” java.lang.IndexOutOfBoundsException: Index: 0, Size: 0″ with ArrayList?
- How do I limit the number of decimals printed for a double?
- Unfortunately MyApp has stopped. How can I solve this?
- exception in thread ‘main’ java.lang.NoClassDefFoundError:
- java.io.FileNotFoundException: the system cannot find the file specified
- How to parse this string in Java?
- How to match “any character” in regular expression?
- Double array initialization in Java
- Explain the use of a bit vector for determining if all characters are unique
- java.text.ParseException: Unparseable date
- Convert java.util.Date to String
- How do I do a deep copy of a 2d array in Java?
- Returning an empty array
- Java Security: Illegal key size or default parameters?
- Could not reserve enough space for object heap
- Eclipse: Java was started but returned error code=13
- Why java unknown: import org.apache.commons.codec.binary.Base64;?
- Extracting .jar file with command line
- Java; String replace (using regular expressions)?
- Error: Selection does not contain a main type
- Java, “Variable name” cannot be resolved to a variable
- JRE 1.7 – java version – returns: java/lang/NoClassDefFoundError: java/lang/Object
- Good Java graph algorithm library?
- Integrate Ant builder into Eclipse: Error “Variable references empty selection”
- Convert a byte array to integer in Java and vice versa
- Spring Maven clean error – The requested profile “pom.xml” could not be activated because it does not exist
- Java Class File Editor
- Error Importing SSL certificate : Not an X.509 Certificate
- Java and Windows – error: illegal escape character
- How should I copy Strings in Java?
- Bank Account Java Program
- List of all special characters that need to be escaped in a regex
- No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
- java.lang.ArithmeticException: / by zero
- Eclipse error, “The selection cannot be launched, and there are no recent launches”
- STS launch error – Java was started but returned exit code=13
- RecyclerView onClick
- Java, Shifting Elements in an Array
- error: bad operand types for binary operator ‘&&’
- Exception in thread “main” java.lang.ArithmeticException: / by zero
- Failed to load the JNI shared Library (JDK)
- “com.jcraft.jsch.JSchException: Auth fail” with working passwords
- java.util.NoSuchElementException – Scanner reading user input
- How would I use a while loop to keep requesting user input
- Array Required, but java.lang.String found
- Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project
- difference between equals() and hashCode()
- Adding days to a date in Java
- The C# Shorthand getters and setters
- What’s the reason I can’t create generic array types in Java?
- How to pass an object from one activity to another on Android
- Finding the size of a char array in Java
- Android For loop
- How to draw lines in Java
- Java project in Eclipse: The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
- How to Set the Background Color of a JButton on the Mac OS
- How to easily convert a BufferedReader to a String?
- How can I calculate a time difference in Java?
- Detecting a long press with Android
- How to increase the size of an array in Java?
- What does the Ruby method ‘to_sym’ do?
- Cannot invoke toString() on the primitive type int
- intellij idea – Error: java: invalid source release 1.9
- How fix Error:java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
- Is it okay to throw NullPointerException programmatically?
- Android: how to create Switch case from this?
- Read next word in java
- Convert float to double without losing precision
- Exception in thread “AWT-EventQueue-0” java.lang.OutOfMemoryError: Java heap space
- How do the post increment (i++) and pre increment (++i) operators work in Java?
- Manually throw an exception