请教JAVA编程题“编写一个Applet程序,从键盘输入一个字符串,要求按逆序打印各位字符串”

热心网友

#include void main(){ char a[50],t;int i,j; tline(a,50);for(i=0,j=strlen(a);i热心网友

//字符串反向输出(Applet)import java。applet。*;import t。*;import t。event。*;public class e4 extends Applet implements ActionListener{TextField t1,t2;Label label;Button b1,b2;public void init(){ t1=new TextField(20);t2=new TextField(20);b1=new Button("确定");b2=new Button("清除");label=new Label("请输入一字符串:"); tEditable(false); dActionListener(this); dActionListener(this);add(label);add(t1);add(b1);add(b2);add(t2);}public void actionPerformed(ActionEvent e){if( tSource()==b1){StringBuffer str=new StringBuffer( tText()); str= verse(); tText(null); tText( String());}if( tSource()==b2){ tText(null); tText(null);}}}。

热心网友

StringBuffer类有一个方法叫做reverse(),能把一个StringBuffer对象逆序排列,希望对你有用。

热心网友

难吗?一个数组不就解决了?