【final】关键词

java final的含义:无法改变的;在运行过程中内容不可更改;对于对象,final使引用恒定不变,一旦引用被初始化指向一个对象,就无法改变它指向另一个对象;惯例:static final域用大写表示

  • 一个即是static又是final的域只占据一段不能改变的存储空间,必须在声明的时候进行初始化;为了节省内存
  • final而非static定义的常量可以用构造函数初始化
  • 空白final必须在构造器中使用表达式对其赋值

final类:final类禁止继承,不会有子类,final类中所有方法都隐式指定为是final的,因此无法覆写这些方法。

final方法:final把该方法锁住,确保在继承中该方法行为保持不变,并且不会被覆写;

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: