zoukankan      html  css  js  c++  java
  • hw1 problem2

    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

  • 相关阅读:
    使用合理jQuery选择器查找DOM元素
    DOM对象和jQuery对象
    jQuery实现返回顶部
    行内元素,块级元素
    图片自适应缩放
    幽灵按钮
    background-attachment:fixed
    RegExp
    正则
    Date
  • 原文地址:https://www.cnblogs.com/Jingjunw/p/7182488.html
Copyright © 2011-2022 走看看