首页 > 其他 > 详细

hw1 problem2

时间:2017-07-15 14:33:48      阅读:279      评论:0      收藏:0      [点我收藏+]

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!