JAVA 基础

 

一,Primitive Data Types and Operations

Variables: datatype variableName

Constants: final datatype CONSTANTNAME = VALUE

 

<!--[if !supportMisalignedColumns]--><!--[endif]-->

Numeric Data Types and Operations

 

byte

short

int

long

float

double


           

 

Shorthand Operators

+=

-=

*=

/=

%=

i++

i--

++i

--i

 

 

Numeric Type conversions

    ----------------------------------------->

byte

short

int

long

float

double

           

 

二,Method

Creating a Method:

 

modifier retrunValueType methodName (list of paraments){ //method body; }
   

 

 

 三,Array

 

dataType[] arrayRefVar; dataType arrayRefVar[];

 

 

dataType[] arrayRefVar = new dataType[arraySize]; dataType arrayRefVar[] = new dataType[arraySize];

 

 

 

 

三,String and Text I/0

 

Constructing String

String a = new String(“hello”);

String Comparisons

if (string1.equals (stirng2))  or  s1.compareTo(s2)

String Concatenation

s3 = s1.concat(s2)   or  s3 = s1 + s2

Obtaining Substrings

substring(beginIndex, endIndex); substring(index)

String Conversions

toLowerCase, toUpperCase, trim, replace(‘e’,’A’)

Finding a Character/subSting

indexOf

Conversion Array/String

toCharArray(), valueOf(xxx);

 

四,Inheritance and polymorphism

Using the super Keyword: The keyword super  refers to the superclass of the class in which super appears, it can be used in two ways:

1.         To call a superclass constructor

2.         To call a superclass method

 

Casting Objects and the instanceof Operator

 

The final Classes, Methods and Variables

The equals Method

The hashCode Method

The finalize Method

The clone Method

 

五,Abstract Classes and Interfaces

 

Variables

Constructors

Methods

Abstract class

No retrictions

Constructors are invoked by subclasses through constructor chaining,An abstract class cannot be instantiated using the new operator.

No restrictions

Interface

All variables must public static finel

No constructors.

All methods must be public abstract instance methods

你可能感兴趣的:(java)