将“hello world” 输出为“world hello”
来源:互联网 发布:四年级数学优化 编辑:程序博客网 时间:2024/05/16 12:30
public class Reverset1{
//将“hello world” 输出为“world hello”
public static void main(String[] args) {
String s="hello world!";
System.out.println(change(s));
}
public static String change(String s){
//使用String工具类将字符串进行分解
StringTokenizer st = new StringTokenizer(s);
ArrayList<Object> list = new ArrayList<Object>();
while(st.hasMoreElements()){
list.add(st.nextElement());
}
StringBuffer s2 = new StringBuffer();
int j=0;
for (int i = list.size()-1; i >=0; i--) {
s2.append(list.get(i)+" ");
}
return s2.toString();
}
}
public class Reverset2{
//将“hello world” 输出为“world hello”
public static void main(String[] args) {
String s="hello world!";
System.out.println(change(s));
}
public static String change(String s){
for (int i = s2.length-1; i >=0; i--) {
sf.append(s2[i]+" ");
}
return sf.toString();
}
}
//将“hello world” 输出为“world hello”
public static void main(String[] args) {
String s="hello world!";
System.out.println(change(s));
}
public static String change(String s){
//使用String工具类将字符串进行分解
StringTokenizer st = new StringTokenizer(s);
ArrayList<Object> list = new ArrayList<Object>();
while(st.hasMoreElements()){
list.add(st.nextElement());
}
StringBuffer s2 = new StringBuffer();
int j=0;
for (int i = list.size()-1; i >=0; i--) {
s2.append(list.get(i)+" ");
}
return s2.toString();
}
}
public class Reverset2{
//将“hello world” 输出为“world hello”
public static void main(String[] args) {
String s="hello world!";
System.out.println(change(s));
}
public static String change(String s){
StringBuffer sf = new StringBuffer();0
//利用字符串的分割
String[] s2 = s.split(" ");for (int i = s2.length-1; i >=0; i--) {
sf.append(s2[i]+" ");
}
return sf.toString();
}
}
阅读全文
0 0
- 将“hello world” 输出为“world hello”
- 将字符串【"Hello world" 】 倒序结果为【"world Hello " 】
- 输出"HELLO WORLD" ASM
- 汇编程序输出“Hello world”
- django输出 hello world
- php 输出Hello World
- 页面输出Hello World
- Java:输出Hello World!
- 1.5 输出Hello World
- python输出Hello World
- 输出hello world
- 这样输出“Hello World”
- Hello World!【Hello World】
- hello world 输出 olleh dlrow
- PHP之输出"hello World"
- C#控制台 输出hello world
- 使用vuejs输出Hello world
- 使用reactjs输出Hello world
- Windows Server 2016设置网卡的顺序
- java的设计模式
- spark job server on Spark1.6.0-CDH5.11.0初步使用
- Redis数据结构-链表
- ZigBee CC2530 Z-Stack 27 终端设备低功耗模式与电池寿命1-理论
- 将“hello world” 输出为“world hello”
- POJ
- C语言实现矩阵的转置
- Titanic: Machine Learning from Disaster
- mysql 存储过程(临时表、循环、游标综合运用)
- 07_
- WindowsError的错误代码详解
- UVALive 7272 Promotions【拓扑排序】【bitset】
- Eclipse 修改背景图片(不是修改背景颜色)