Java static method instance method specific differences and links, java instance
When you read the JDK documentation, you will often see a summary of methods of a class, which is generally listed in the following format:
What are the meanings of the methods corresponding to these labels?
1. Static Method: Static Method. You can access the Static Method without creating a class instance. For example, to access the static valueof String class, you can directly reference String. valueof. The Code is as follows:
1 package com. company; 2 3 public class Main {4 5 public static void main (String [] args) {6 boolean test = false; 7 String str = String. valueOf (test); 8 System. out. println (str); 9 // The output string is false10 11} 12}
2. Instance Method: the Instance Method. This is relative to the static Method. Unlike the static Method, the Instance Method can be referenced only after the class Instance is created. For example, the charat method of the String class, the Code is as follows:
1 package com. company; 2 3 public class Main {4 5 public static void main (String [] args) {6 7 String str2 = "abc"; 8 char c = str2.charAt (0 ); 9 System. out. println (c); 10 // The output is a11 12} 13}
3. Concrete Method. The specific method is relative to the abstract Method of the abstract method. An abstract method has no method body. Its concrete implementation is implemented by the subclass of the abstract class where the abstract method is located. Generally, the methods in the standard library are specific methods. The static methods and instance methods mentioned above all have method bodies, which are called "specific methods ".
4. deprecated Method, Deprecate, do not agree; as the name suggests, it is not recommended to use the Method; with JDK update, some methods are discarded, or the update is stopped, this method is usually labeled as deprecated method.