Sie sind auf Seite 1von 4

04.08.

2016

JavaAllinOneForDummiesCheatSheetForDummies

CheatSheet

JavaAllinOneForDummies
FromJavaAllinOneForDummies,4thEditionbyDougLowe
WritingJavastatements(likeforandif)andclasses(likeMathandNumberFormat)helpyoustartandbuild
strongprograms.VariablesholddifferentkindsofJavadatatypes:numbers,characters,andtrue/falsenumbers.
YoudesignateJavaoperationsthatcanbeperformedonoperands,includingarithmeticoperators,relational
operators(orbinary)andlogicaloperators(orBoolean).

CommonJavaStatements
Javastatementsbuildprograms.EveryJavaclassmusthaveabody,whichis
madeupofoneormorestatements.Youcanwritedifferentkindsof
statements,includingdeclarationandexpression.

Thebreakstatement
break

Thecontinuestatement
continue

Thedostatement
do
{statements...}
while(expression)

Theforstatement
for(inittestcount)
{statements...}

Theenhancedforstatement
for(typevariable:arrayor
collection)
{statements...}

Theifstatement
if(expression)
{statements...}
else
{statements...}

Thethrowstatement
throw(exception)

Theswitchstatement
switch(expression)
{
caseconstant:
statements
break
default:
statements
break
}

Thewhilestatement
http://www.dummies.com/howto/content/javaallinonefordummiescheatsheet.navId821099.html?print=true

1/4

04.08.2016

JavaAllinOneForDummiesCheatSheetForDummies

while(expression)
{statements...}

Thetrystatement
try
{statements...}
catch(exceptionclasse)
{statements...}...
finally
{statements...}
try
{statements...}
finally
{statements...}

PrimitiveDataTypes
Javadatatypesarethekindofdatayoucanstoreinavariable.Primitivedata
typesaredefinedbythelanguageitself.Javadefinesatotalofeightprimitive
types.Oftheeightprimitivedatatypes,sixarefornumbers,oneisfor
characters,andoneisfortrue/falsevalues.Ofthesixnumbertypes,fourare
typesofintegers,andtwoaretypesoffloatingpointnumbers.
Type

WrapperClass

ParseMethodofWrapperClass

int

Integer

intparseInt(Strings)

short

Short

shortparseShort(Strings)

long

Long

longparseLong(Strings)

byte

Byte

byteparseByte(Strings)

float

Float

floatparseFloat(Strings)

double

Double

doubleparseDouble(Strings)

char

Character

(none)

boolean

Boolean

booleanparseBoolean(Strings)

MathandNumberFormatClasses
Javaclasseslaythefoundationforyourprograms.TheJavaMathand
NumberFormatclassesletyouprogramnumbervalues,aswellasformat
numbersandcurrencies.

TheMathClass
Method
numabs(numy)

Description
Absolutevalueofy(numcanbeanynumeric
datatype)

nummax(numy,num
z)

Maximumofyandz

nummin(numy,num
z)

Minimumofyandz

double=Math.

Randomnumber,suchthat0.0<x<=1.0

http://www.dummies.com/howto/content/javaallinonefordummiescheatsheet.navId821099.html?print=true

2/4

04.08.2016

JavaAllinOneForDummiesCheatSheetForDummies

random()

TheNumberFormatClass
Method

Description

NumberFormat
getNumberInstance()

Getsaninstancethatformats
numbers.

NumberFormat

Getsaninstancethatformats
currency.

Stringformat(x)

Formatsthespecifiednumber.

JavaOperators
Anoperatordesignatesamathematicaloperationorsomeothertypeof
operationthatcanbeperformedonoperands.Javahasarithmeticoperators,
relationaloperators(alsoknownasbinaryoperators)andlogicaloperators
(alsoknownasBooleanoperators).

Arithmetic
Operator

Description

Addition

Subtraction

Multiplication

Division

Remainder

++

Increment

Decrement

+=

Additionandassignment

Subtractionandassignment

*=

Multiplicationandassignment

/=

Divisionandassignment

%=

Remainderandassignment

Relational
Operator

Description

==

Equal

!=

Notequal

<

Lessthan

<=

Lessthanorequalto

>

Greaterthan

>=

Greaterthanorequalto

Logical
Operator

Description

http://www.dummies.com/howto/content/javaallinonefordummiescheatsheet.navId821099.html?print=true

3/4

04.08.2016

JavaAllinOneForDummiesCheatSheetForDummies

Not

&

And

&&

Conditionaland

Or

||

Conditionalor

xor

Aboutus

MoreFromDummies

TopicsAZ

AboutForDummies
ContactUs
PrivacyPolicy
TermsandConditions
AdvertisewithUs
ManageYourEMail
Newsletters
Help

MobileSite
MyAccount
DummiesB2BServices
OnlineTestBanks
eLearning
MobileApps
DummiesStore
Sweepstakes

SmallBusiness&Careers
Computers&Software
ConsumerElectronics
Crafts&Hobbies
Education&Languages
Food&Drink
Games
Health&Fitness

Home&Garden
Internet&SocialMedia
Music&CreativeArts
PersonalFinance
Pets
Photography&Video
Relationships&Family
Religion&Spirituality
Sports&Outdoors

Copyright2016&TrademarkbyJohnWiley&Sons,Inc.Allrightsreserved.

http://www.dummies.com/howto/content/javaallinonefordummiescheatsheet.navId821099.html?print=true

4/4

Das könnte Ihnen auch gefallen