zoukankan      html  css  js  c++  java
  • 【API】反转输入字符(Java)

    请求输入字符,

    输出反转。

     1 import java.util.Scanner;
     2 
     3 public class T01 {
     4 
     5     public static void main(String[] args) {
     6         /**
     7          * get str from kbd
     8          * out a new str that sakasamad
     9          */
    10         System.out.print("in put a str :  | ");
    11         String str = new Scanner(System.in).nextLine();
    12         str = new StringBuilder(str).reverse().toString();
    13         System.out.print("FanZhuan :      | "+str);
    14         
    15         System.out.println("
    - -------------- --- -
    ");
    16         
    17         System.out.print("in put a str :  | ");
    18         System.out.print("FanZhuan :      | "+new StringBuilder(new Scanner(System.in).nextLine()).reverse().toString());
    19     
    20     
    21         //well... i don't know how to use close() now...    
    22     }
    23 }

    试了试行数更少的写法,还真也行,输出效果没有坏掉。

    ----

    话说玩API比搞项目舒服多了……

  • 相关阅读:
    python 爬虫 urllib模块 url编码处理
    python 爬虫 urllib模块 目录
    python 爬虫 urllib模块介绍
    python 爬虫 目录
    爬虫 介绍
    POJ 2533
    POJ 2531
    POJ 2524
    POJ 2505
    POJ 2521
  • 原文地址:https://www.cnblogs.com/senwren/p/str_sakasama_Java.html
Copyright © 2011-2022 走看看