Learn more about final

package test10;
/*
 * 1. Abstract classes cannot be final modified
 * 2. Abstract methods cannot be final modified
 * 3. Final modified reference type, the reference cannot be re-pointed to other java objects
 * But the final modified reference, the The properties of the java object pointed to by the reference can be modified
 */
public class test10 {
public static void main(String[] args) {
final customer c=new customer("jack",15);
//The memory address saved in c It can be unchanged, it can only point to c
//c=new customer("lucy",20); c is final and cannot be assigned any more } }


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325891348&siteId=291194637