Java03 InputLine

It’snoteasyfornewcomertolearnjava-application’siostream.

NowfromwhatIlearn,IshouldcreataReadertoreadwhattheusertype,thencreateaBufferedReadertostorethekeywords.AfterdoingthatIcancreateStringtoreadLine().

Hereisthemethods:

publicstaticStringinputLine(){

BufferedReaderbr=null;

Readerr=newInputStreamReader(System.in);

br=newBufferedReader(r);

Stringstr="";

try{

str=br.readLine();

}catch(IOExceptione){

e.printStackTrace();

}

returnstr;

}

Bytheway,WhenIwanttogetanint,Ishouleconvertthestring.

Integer.parseInt(inputLine());

努力爱一个人。付出,不一定会有收获;

Java03 InputLine

相关文章:

你感兴趣的文章:

标签云: