tnfh.net
当前位置:首页 >> 用jAvA编写一段程序,输入一段字符串,然后输出该... >>

用jAvA编写一段程序,输入一段字符串,然后输出该...

类名:Invert import java.util.Scanner; public class Invert { public static void main(String[] args) { Scanner input=new Scanner(System.in); String str=input.next(); char[] strm=str.toCharArray(); for(int i=0;i

public class Main { public static void main(String[] args) { System.out.println(revertString("abcdefg")); } public static String revertString(String origin) { if (origin == null) { return null; } char[] arr = origin.toCharArray...

import java.util.*;public class Yugi { public static void main(String[] args) { Scanner scan = new Scanner(System. in ); String line = scan.nextLine().trim(); scan.close(); HashMap < Character, Integer > map = new HashMap < Cha...

如果是字符串的话,可以通过以下方式逆序输出: public class reverseTest {public static void main(String[] args) {String originalString = "abcdefg";StringBuffer stringBuffer = new StringBuffer(originalString);System.out.println(st...

自己参考下吧 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Test { public static void main(String[] args){ BufferedReader br = null; String s = ""; String s1 = ""; try{...

import java.util.Scanner;public class Main {public static void main(String args[]){Scanner scanner=new Scanner(System.in);String s=scanner.next();System.out.println(s);}}这是输出第一个单词如果只要字符的话将System.out.println(s)...

一下代码仅供参考 public class Main {public static void main(String[] args) {String s = "aaBvdEFdsd";StringBuffer ss = convertString(s);System.out.println("大小写转换后是:" + convertString(s));System.out.println("倒序输出后是:" ...

public static String reverse(String s){ StringBuffer ns =new StringBuffer(); for(int i=s.length()-1;i>=0;i--){ ns.append(s.charAt(i)+""); } return ns.toString(); }

import java.util.Scanner; public class FruitImp { public static void main(String[] args) { String str = new Scanner(System.in).nextLine(); //用一个二维数组存放字符和对应的字数 //用数组的缺点是空间浪费 可以用map 或别的代替这里就...

转换符串的大小写,方法如下: public class StringCast { // 大小写转换方法 public void cast() { // 定义字符串 String string = "AILltDRGVTzmugNhuiLio"; // 将定义好的字符串转换为字符数组 char[] charArray = string.toCharArray(); // ...

网站首页 | 网站地图
All rights reserved Powered by www.tnfh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com