码迷,mamicode.com
首页 > 其他好文 > 详细

hw1 problem2

时间:2017-07-15 14:55:36      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:puts   port   sys   flush   tput   hello   input   更改   cto   

problem 2没什么好说的,用了String里的substring() 和concat()method。看地里有人说可以新建一个StringBuilder constructor,然后用里面的deleteCharAt()method  试了一下是可以的,还要再用一个toString() method  把类型转换回String. 在String上做什么更改都可以启用StringBuilder。

code:

import java.io.*;

public class Nuke2 {

public static void main(String[] arg) throws Exception {

 

     System.out.print("Plese input you word: ");

     System.out.flush();  

     BufferedReader keyboard=new BufferedReader(new InputStreamReader(System.in));

     String inputLine=keyboard.readLine();

     String omitted1=inputLine.substring(0,1);

     String omitted2=inputLine.substring(2);

     String OutPut=omitted1.concat(omitted2);

     System.out.println(OutPut);

}

}

 

 

output

Plese input you word: hello

hllo

 

hw1 problem2

标签:puts   port   sys   flush   tput   hello   input   更改   cto   

原文地址:http://www.cnblogs.com/Jingjunw/p/7182488.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!