Java 知识测试 Java final keyword Question 1 What is the use of final keyword in Java? A. When a class is made final, a sublcass of it can not be created. B. When a method is final, it can not be overridden. C. When a variable is final, it can be assigned…
In this tutorial we will learn the usage of final keyword. final keyword can be used along with variables, methods and classes. We will cover following topics in detail. 1) final variable2) final method3) final class 1. Final Variables final variable…
final修饰变量表示变量初始化后就不能再改变. 一.对于基础类型来说,用final修饰后其值不可以改变. 1. final int a; a = 5; 2.final int a = 5; 二.对于引用类型来说,用final修饰后其引用的对象不可改变,但可以改变对象的内容. java中用final修饰函数的参数,只是函数体内不能修改这个形参所指向的对象,但是仍能修改对象内容 void f ( final String str){ str = new String();//不允许 str.to…