Common modifiers used by classes and their components in Java

Source: Internet
Author: User
Tags modifier modifiers

common modifiers used by classes and their components in Java
(1) Classification of modifiers:  
Permission modifiers:private, default, protected,     public
status modifiers:static, Final    
abstraction modifier:    Abstract
(2) modifiers used for common classes and their composition:  
of the Modified class:    
There are: default, public, final, abstract      
examples are as follows:
class Demo {}//default modifier
Public class Demo {}
the final class Demo {}///End classes cannot be inherited.
abstract class Demo {}//Abstraction classes
modifiers for common classes: public class Demo {}      
---------------------------------------
to modify a member variable:    
available: Private, default, protected, public, static, final
examples are as follows:        
private int x = ten;
int y =;
protected int z =;
public int a = +;
Public final int b =;
public static int c =;
Public static final int d =;
modifiers for common member variables: private int x = ten;      
---------------------------------------
to modify the construction method:
available: Private, default, protected, public
examples are as follows:
Private Demo () {}
Demo (String name) {}
protected Demo (String name, int age) {}
Public Demo (string name, int age, string address) {}
modifiers for common construction methods: public Demo (string name, int age, string address) {}      
---------------------------------------
to modify a member method:
available: Private, default, protected, public, static, final, abstract
examples are as follows:
private void Show () {}
void Show () {}
protected void Show () {}
Public Void Show () {}
static void Show () {}
abstract void Show ();
final void Show () {}
modifiers for common member methods: public void Show () {}      
---------------------------------------
(3) Other common combination rules:
examples are as follows:
to modify a member variable:      
Public static final int x = 10;//defines a static final variable (constant)
to modify a member method:      
Public static void Show () {}
Public final void Show () {}
Public abstract void Show ();
-----------------------------------------------------------------------------

Common modifiers used by classes and their components in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.