function  MyDecode(s);  
function  MyDecode(str)  {...}这样的方法定义是错误的。
把function  MyDecode(s);改成:MyDecode(s);   
把function  MyDecode(str){...}挪到类体外面,改成:void MyDecode(String str){...}方法内部不能用var,而应该写明变量类型,如int、String等。String类的子串方法是substring不是substr。取得char数组的方法是toCharArray。......问题多多,可能需要从基础看起。找本入门书或者语法书看看。

解决方案 »

  1.   

    很多错误啊
    建议:买本JAVA的教材,看一下吧
    如果学过其他语言,学JAVA不难的
      

  2.   

    今天闲着没事,改了一下楼主的程序,仔细看了一下功能,是要实现加密的吗?:
    import  java.awt.*;  
    public  class  Demo  
    {  
               public  static  void  main(String[]  a)  
               {  
                           String  s;  
                           s="rongxiao";  
                            MyDecode(s);  
                            
               }  
               public static void MyDecode(String str)  
               {  
                           String  c="";  
                           String[]  arrCodes  =  {"g","f","w","v","h","z","t","i","y","s","u","x","a","r","j","b","k","q","n","c","o","l","d","p","m","e","]","?","#","%","*","\n"};  
                           String[]  arrChars  =  {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","<",">","/","\"","!","@"};  
                           boolean bCode;
                           for(int i=0;i<str.length()-1;i++)  
                           {  
                                       bCode  =  false;  
                                       for(int j=0;j<32;j++) { 
                                         //System.out.println(str.substring(i,  i+1)+"   "+arrCodes[j]);
                                                   if(str.substring(i,  i+1).equals(arrCodes[j]))  
                                                   {  
                                                               c  =  c  +  arrChars[j];  
                                                               bCode  =  true; 
                                                               System.out.println(c);   
                                                               break;  
                                                   }  
                                                  }
                                                   
                                       if(bCode==false)  System.out.println(str.substring(i,  i+1)+" no found!");
                                                  // c  =  c  +  str.substring(i,  1);  
                           }  
                           
               }  
                 
    }
    此段程序运行通过。
      

  3.   

    原来学VB的吧。
    先找本入门书看看,把语法习惯改过来。然后学习JAVA的OO特点,熟悉JAVA的各类库。这样才算真正上路了。