Variables for the Java Foundation

Source: Internet
Author: User

A variable is the name of a memory location.

1. member variables (instance variables, attributes)

A member variable is a property in a class, and each object has a copy of the property when the object is created. A property in an object is a member variable.

2. Local variables (local variables)

A variable declared within a method is called a local variable, and only that method can access it.

3. Class variables (static variables)

staticthe variable declared is called a static variable and cannot be declared as local. You can use the class name. Property Access.

Example:

class Person {    int : age =;                 //Member variables    Static // Static Variables    void eat () {        int n = +;               // Local Variables     }}

A variable cannot be a system-reserved keyword:

For example:

int Private // this is not allowed.

Schedule: Java system reserved Keywords

Access control

Private

Protected

Public

 

classes, methods, and variables

modifier

abstract

class

extends

Final

Implements

interface

native

new

static

strictfp

Synchronized

transient

volatile

         

 

Program Control

break

Continue

return

do

while

if

Else

for

instanceof

switch

Case

default

           

error handling

Try

Catch

Throw

throws

         

Package related

Import

Package

             

 

Basic type

Boolean

Byte

Char

Double

float

int

Long

Short

Null

True

False

             

variable reference

Super

This

void

           

Reserved words

Goto

Const

Variables for the Java Foundation

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.