English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2 answers

Here is a simple way:


public class StringStuff {

public static void main(String[] args) {

String input = null;
if (args.length > 0){
input = args[0];
} else {
input = "How now brown cow?";
}
StringBuffer sb = new StringBuffer(input);
sb.reverse();
String output = sb.toString();
System.out.println(output);

}

}

2006-10-30 09:03:38 · answer #1 · answered by vincentgl 5 · 0 0

I think you need at least 2 string functions - .length() and .charAt():

public class Cl {
public static void main(String[] args) {
String before = "A Sample String", after = "";
for (int i = 0; i < before.length(); ++i) after += before.charAt(i);
}
}

2006-10-28 08:45:06 · answer #2 · answered by nikaustr 2 · 0 0

fedest.com, questions and answers