在Linux中实现https访问站点
2012-08-22 13:00
453 查看
1)Thetokenizerisagreedytokenizer.Itgrabsasmanycharactersasitcantobuildupthenexttoken,notcaringifthiscreatesaninvalidseuenceoftokens.
publicclassTest{
publicstaticvoidmain(String[]args){
inti=1;
inta=i+++i;//equalsto:i+++i
System.out.println(a);
}
}
2)Everytype(primitiveorreference)hasanassociatedinstanceofclassClassthatrepresentsthattype.Theseinstancesareoftenreferredtoastheclassobjectforagiventype.Youcannametheclassobjectforatypedirectlybyfollowingthetypenamewith".class",asin
publicclassClassObject{
publicstaticvoidmain(String[]args){
System.out.println(java.lang.String.class.toString());
}
}
3)Youcandefertheinitializationofafinalfieldorlocalvariable.Suchafinalvariableiscalledablankfinal.Ablankfinalfieldmustbeinitializedwithinaninitializationblockorconstructor(ifit'saninstancefield)whileablankfinallocalvariable,likeanylocalvariable,mustbeinitializedbeforeitisused.
Thecompilerwillverifythatallstaticfinalfieldsareinitializedbytheendofanystaticinitializerblocks,andthatnon-staticfinalfieldsareinitializedbytheendofallconstructionpathsforanobject.Acompile-timeerrorwilloccurifthecompilercannotdeterminethatthishappens.
4)Anarrayobject’slengthisfixedatitscreationandcannotbechanged.Butanewarrayofadifferentsizecouldbeassignedtothearrayvariableatanytime.
int[]ia=newint[3];
intia[]=newint[3];
theprevioustwostatementsareequivalent,however,theformeroneispreferable.
Theimportantthingtorememberisthatthemodifiersapplytothearrayvariablenottotheelementsofthearraythevariablereferences.
5)MultidimensionalArray:
float[][]mat=newfloat[4][4];
Thefirst(left-most)dimensionofanarraymustbespecifiedwhenthearrayiscreated.Otherdimensionscanbeleftunspecified,tobefilledinlater.
float[][]mat=newfloat[4][];
for(inty=0;y<mat.length;y++)
mat[y]=newfloat[4];
6)ArraysareimplicitextensionsofObject.GivenaclassX,classesYandZthatextendX,andarraysofeach,theclasshierarchylookssomethinglikethis:
Thisclassrelationshipallowspolymorphismforarrays.YoucanassignanarraytoavariableoftypeObjectandcastitback.AnarrayofobjectsoftypeYisusablewhereveranarrayofobjectsofitssupertypeXisrequired.Thisseemsnaturalbutcanrequirearuntimecheckthatissometimesunexpected.AnarrayofXcancontaineitherYorZreferences,butanarrayofYcannotcontainreferencestoXorZobjects.ThefollowingcodewouldgenerateanArrayStoreExceptionatruntimeoneitherofitsfinaltwolines,whichviolatethisrule:
Y[]yArray=newY[3];//aYarray
X[]xArray=yArray;//valid:YisassignabletoX
xArray[0]=newY();
xArray[2]=newX();//INVALID:can'tstoreXinY[]
xArray[1]=newZ();//INVALID:can'tstoreZinY[]
Likeanyotherobject,arraysarecreatedandaresubjecttonormalgarbagecollectionmechanisms.TheyinheritallthemethodsofObjectandadditionallyimplementtheCloneableinterfaceandtheSerializableinterface.
7)
Toavoidconfusion,hidingisnotpermittedinnestedscopeswithinacodeblock.Thismeansthatalocalvariableinamethodcannothavethesamenameasaparameterofthatmethod;thataforloopvariablecannothavethesamenameasalocalvariableorparameter;andthatoncethereisalocalvariablecalled,say,über,youcannotcreateanew,differentvariablewiththenameüberinanestedblock.
Example1:
{
intüber=0;
{
intüber=2;//INVALID:alreadydefined
//...
}
}
Example2:
voidprint(intval){
for(inti=0;i<100;++i){
intval=100;//invalid:Duplicatelocalvariableval
}
}
Example3:
voidprint(){
intval=1;
for(inti=0;i<100;++i){
intval=100;//invalid:Duplicatelocalvariableval
}
}
Example4:
2)Everytype(primitiveorreference)hasanassociatedinstanceofclassClassthatrepresentsthattype.Theseinstancesareoftenreferredtoastheclassobjectforagiventype.Youcannametheclassobjectforatypedirectlybyfollowingthetypenamewith".class",asin
String.class java.lang.String.class java.util.Iterator.class boolean.class SinceclassClassisgeneric,theactualtypeoftheclassliteralforareferencetypeTisClass<T>,whileforprimitivetypesitisClass<W>whereWisthewrapperclassfor
thatprimitivetype.Butnote,forexample,thatboolean.classandBoolean.classaretwodifferentobjectsoftypeClass<Boolean>.
Example:
Output:
classjava.lang.String
3)Youcandefertheinitializationofafinalfieldorlocalvariable.Suchafinalvariableiscalledablankfinal.Ablankfinalfieldmustbeinitializedwithinaninitializationblockorconstructor(ifit'saninstancefield)whileablankfinallocalvariable,likeanylocalvariable,mustbeinitializedbeforeitisused.
Thecompilerwillverifythatallstaticfinalfieldsareinitializedbytheendofanystaticinitializerblocks,andthatnon-staticfinalfieldsareinitializedbytheendofallconstructionpathsforanobject.Acompile-timeerrorwilloccurifthecompilercannotdeterminethatthishappens.
4)Anarrayobject’slengthisfixedatitscreationandcannotbechanged.Butanewarrayofadifferentsizecouldbeassignedtothearrayvariableatanytime.
intia[]=newint[3];
theprevioustwostatementsareequivalent,however,theformeroneispreferable.
Theimportantthingtorememberisthatthemodifiersapplytothearrayvariablenottotheelementsofthearraythevariablereferences.
5)MultidimensionalArray:
Thefirst(left-most)dimensionofanarraymustbespecifiedwhenthearrayiscreated.Otherdimensionscanbeleftunspecified,tobefilledinlater.
for(inty=0;y<mat.length;y++)
mat[y]=newfloat[4];
6)ArraysareimplicitextensionsofObject.GivenaclassX,classesYandZthatextendX,andarraysofeach,theclasshierarchylookssomethinglikethis:
Thisclassrelationshipallowspolymorphismforarrays.YoucanassignanarraytoavariableoftypeObjectandcastitback.AnarrayofobjectsoftypeYisusablewhereveranarrayofobjectsofitssupertypeXisrequired.Thisseemsnaturalbutcanrequirearuntimecheckthatissometimesunexpected.AnarrayofXcancontaineitherYorZreferences,butanarrayofYcannotcontainreferencestoXorZobjects.ThefollowingcodewouldgenerateanArrayStoreExceptionatruntimeoneitherofitsfinaltwolines,whichviolatethisrule:
X[]xArray=yArray;//valid:YisassignabletoX
xArray[0]=newY();
xArray[2]=newX();//INVALID:can'tstoreXinY[]
xArray[1]=newZ();//INVALID:can'tstoreZinY[]
Likeanyotherobject,arraysarecreatedandaresubjecttonormalgarbagecollectionmechanisms.TheyinheritallthemethodsofObjectandadditionallyimplementtheCloneableinterfaceandtheSerializableinterface.
7)
Toavoidconfusion,hidingisnotpermittedinnestedscopeswithinacodeblock.Thismeansthatalocalvariableinamethodcannothavethesamenameasaparameterofthatmethod;thataforloopvariablecannothavethesamenameasalocalvariableorparameter;andthatoncethereisalocalvariablecalled,say,über,youcannotcreateanew,differentvariablewiththenameüberinanestedblock.
Example1:
intüber=0;
{
intüber=2;//INVALID:alreadydefined
//...
}
}
Example2:
for(inti=0;i<100;++i){
intval=100;//invalid:Duplicatelocalvariableval
}
}
Example3:
intval=1;
for(inti=0;i<100;++i){
intval=100;//invalid:Duplicatelocalvariableval
}
}
Example4:
相关文章推荐
- Linux下利用Https实现站点访问
- Linux实现https方式访问站点
- linux下利用https实现站点访问
- 在linux中实现https访问web站点的配置
- linux实现https方式访问站点
- Linux实现https方式访问站点
- 在Linux中实现https访问web站点
- 在Linux中实现https访问web站点
- 利用https实现站点的访问
- 在linux系统中利用https访问站点
- WDCP上配置SSL证书即https 2017-08-28 百度总结 操作环境:linux的WDCP操作面板(没有操作面板就在命令行操作) wdcp 安装ssl证书教程实现https访问 1.申请
- Linux使用curl访问https站点时报错汇总
- 利用https实现站点的访问
- 利用https实现站点的访问
- HTTPS加密访问Web站点的实现和虚拟站点的实现例析(二)
- 利用https实现站点的访问
- Linux中使用curl命令访问https站点4种常见错误和解决方法
- 利用https实现站点的访问
- Linux系统下自建CA实现https访问
- 利用https实现站点访问