鱼C论坛

 找回密码
 立即注册
楼主: 零度非安全

[技术交流] Java 小练习(002):将 This is a test 倒着输出 tset a si sihT(20170219)

[复制链接]
发表于 2018-3-7 10:26:19 | 显示全部楼层
  1. package stage_0;

  2. public class reverse {

  3.         public static void main(String[] args) {
  4.                 StringBuffer a = new StringBuffer(" tset a si sihT");
  5.                 reverse c = new reverse();
  6.                 c.pig(a);
  7.         }
  8.        
  9.         public void pig(StringBuffer a) {
  10.                 StringBuffer b = new StringBuffer();
  11.                 for (int i = 0; i < a.length(); i++) {
  12.                         b.insert(0, a.charAt(i));
  13.                 }
  14.                 System.out.println(b);
  15.         }
  16. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-8-24 14:43:53 | 显示全部楼层
看下
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-1 13:15:25 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-10 19:38:26 | 显示全部楼层
public class Test {

        public static void main(String[] args) {
         StringBuffer test=new StringBuffer("This is a test");
         test.reverse();
         System.out.println(test);
        }

}
可以不
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-11 09:12:43 | 显示全部楼层
看看怎么做
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-11 22:13:09 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-17 18:58:01 | 显示全部楼层
666
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-19 09:50:59 | 显示全部楼层
哈哈哈 路过瞅瞅
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-20 09:28:59 From FishC Mobile | 显示全部楼层
谢谢
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-9-25 11:25:33 | 显示全部楼层
  1. public class Str {

  2.         public static void main(String[] args) {
  3.                 String a ="This is a test";
  4.                 char [] b = a.toCharArray();
  5.                 for(int i=b.length-1;i>=0;i--) {
  6.                         System.out.print(b[i]);
  7.                 }

  8.         }

  9. }
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-25 13:50:49 | 显示全部楼层
本帖最后由 blackroot 于 2018-9-25 13:57 编辑
cnkizy 发表于 2017-5-6 12:35
直接用Stack啊,或者一个for倒序输出也可以啊,for(int i=txt.length-1;i>=0;i--)print(txt.charAt(i));


字符串没有length属性,只有length().
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-25 13:58:18 | 显示全部楼层
cnkizy 发表于 2017-5-6 12:35
直接用Stack啊,或者一个for倒序输出也可以啊,for(int i=txt.length-1;i>=0;i--)print(txt.charAt(i));

字符串没有length,只有length()
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-9-25 14:07:13 | 显示全部楼层
public class TestStr{
        public static void main(String arg[]){
                String str = "this is a test";
                StringBuffer sb = new StringBuffer(str);
                sb.reverse();
                System.out.print(sb);
        }
}               
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-3 20:25:24 | 显示全部楼层
6666
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2018-10-11 21:13:50 | 显示全部楼层
学习学习
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-25 17:30:45 | 显示全部楼层
public class Test1{
        public static void main(String []args) {
                StringBuffer a = new StringBuffer("This is a test");
                StringBuffer b = a.reverse();
                System.out.println(b);
        }
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-25 20:09:49 | 显示全部楼层
public class Test1{
        public static void main(String []args) {
                String s = "This is a test";
                for(int i=s.length()-1;i>=0;i--) {
                        System.out.print(s.charAt(i));
                }
        }
}
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-27 09:26:35 | 显示全部楼层
                StringBuffer str1 = new StringBuffer("This is a text");
                str1.reverse();
                System.out.println(str1);
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-10-31 16:03:04 | 显示全部楼层
asdad a
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-3-29 15:21:42 | 显示全部楼层
6666
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-25 02:35

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表