Java:如何使用“import.java.util.*”反转多个字符串那是用户依赖的吗?
我已经有了一个程序..但我唯一想添加的是反转它..我使用了一个类..其中一个是主类..
主类:
public maonajudni() { }
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter how many stringz");
int x = in.nextInt();
String applearray[] = new String[x];
for(int i = 0 ; i < x ; i++){
applearray[i] = in.next();
}
nospance gstonako = new nospance();
gstonako.sortme(applearray , x);
gstonako.uppervowel(applearray , x);
}
这
是类:
class nospance {
public static void main(String[] args) {
}
public void sortme(String s[] , int y){
String tmp="";
for(int j = 0 ; j < y ; j++){
for(int k = 0 ; k < y ; k++){
if(s[j].compareToIgnoreCase(s[k])<1){
tmp = s[j];
s[j] = s[k];
s[k] = tmp;
}
}
}
}
, int z){
String tmp = "";
for(int j = 0 ; j < z ; j++){
System.out.println("");
for(int k = 0 ; k < arr[j].length() ; k++){
if(arr[j].charAt(k)=='A' || arr[j].charAt(k)=='a'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='E' || arr[j].charAt(k)=='e'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='I' || arr[j].charAt(k)=='i'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='O' || arr[j].charAt(k)=='o'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='U' || arr[j].charAt(k)=='u'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
public void uppervowel(String arr[ ] 别的{
System.out.print(""+ arr[j].charAt(k));
}
}
}
} 这
已经是一个正在运行的程序。有人可以帮我添加反转输入的字符串吗?请并谢谢你。我使用的是JCreator Pro和jdk 1.7.0。
i already had a program.. but the only thing i want to add is reverse it.. i used one class.. and one is the main class..
main class:
public maonajudni() {
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter how many stringz");
int x = in.nextInt();
String applearray[] = new String[x];
for(int i = 0 ; i < x ; i++){
applearray[i] = in.next();
}
nospance gstonako = new nospance();
gstonako.sortme(applearray , x);
gstonako.uppervowel(applearray , x);
}
}
this is the class:
class nospance {
public static void main(String[] args) {
}
public void sortme(String s[] , int y){
String tmp="";
for(int j = 0 ; j < y ; j++){
for(int k = 0 ; k < y ; k++){
if(s[j].compareToIgnoreCase(s[k])<1){
tmp = s[j];
s[j] = s[k];
s[k] = tmp;
}
}
}
}
public void uppervowel(String arr[] , int z){
String tmp = "";
for(int j = 0 ; j < z ; j++){
System.out.println("");
for(int k = 0 ; k < arr[j].length() ; k++){
if(arr[j].charAt(k)=='A' || arr[j].charAt(k)=='a'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='E' || arr[j].charAt(k)=='e'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='I' || arr[j].charAt(k)=='i'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='O' || arr[j].charAt(k)=='o'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else if(arr[j].charAt(k)=='U' || arr[j].charAt(k)=='u'){
tmp = tmp + arr[j].charAt(k);
System.out.print(""+tmp.toUpperCase());
tmp = "";
}
else{
System.out.print(""+ arr[j].charAt(k));
}
}
}
}
}
this is already a running program. can someone help me add reverse the inputted strings? please and thank you. I used JCreator Pro and jdk 1.7.0.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用标准 Java 库
,也可以编写自己的函数
You can use standart Java libraries
or you can write your own function