dkfr.net
当前位置:首页 >> jAvA 倒序 >>

jAvA 倒序

初始化的时候应该为str=""; 程序源代码: /* * 字符串abcdefg,要求按逆序输出为gfedcba */ public class ReverseSort { public static String reverseSort(String str) { String str2 = ""; for (int i = str.length() - 1; i > -1; i--) { str...

public static void main(String[] args) { StringBuffer sb = new StringBuffer("abcdefg"); System.out.println(sb.reverse().toString()); }

将字符串倒叙输出有多种方式,下面我罗列两种以作参考: 方法一:利用String类的toCharArray(),再倒序输出数组。 public class javatest { public static void main(String[] args) { String originalString = "abcdefg"; String resultString ...

public class Test{ public static void main(String[] args){ for(int i=9;i>=1;i--){ for(int j=i;j>=1;j--){ System.out.print(i+"*"+j+"="+i*j+"\t"); } System.out.println(); } } }

一、利用String类的toCharArray(),再倒序输出数组。 示例代码: import javax.swing.JOptionPane; public class ReverseString { public static void main (String args[]){ String originalString; String resultString = ""; originalString ...

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.Scanner; public class test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); char[] ch = null; System.out.println("请输入一个十位数的数字"); String str = sc.next(); if (str.trim()....

你好,代码如下: public class ReverseString { public static void main(String[] args) { String str = "ABC" ; for(int i=str.length()-1;i>=0;i--){ System.out.print(str.charAt(i)); } } }

int i = 12343465; int m = 0; while (i != 0) { m =i%10; System.out.print(m); i = i/10; }

方法一:实现Comparable接口排序package collsort.comparable; package com.cvicse.sort.comparable; public class Cat implements Comparable { private int age; private String name; public Cat(int age, String name) { this.age = age; th...

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