ABC.methodname();作为令牌上的语法错误" methodname",此令牌后预期的标识符

时间:2017-04-04 00:30:31

标签: java compiler-errors

  • 我是java新手。
  • 我在这行收到错误ABC.methodname();作为令牌上的语法错误" methodname",此令牌后预期的标识符。
  • 你能告诉我如何解决它。
  • 在下面提供我的全部代码。
from random import shuffle

def create_cipher():

    key = []
    # ASCII value of numerals
    for i in range(48,58):
        key.append(i)
    # ASCII value of lowercase
    for i in range(65,91):
        key.append(i)
    # ASCII value of uppercase
    for i in range(97,123):
        key.append(i)
    print key
    cipher = list(key)
    shuffle(cipher)
    print cipher
    cipher_dict = {}
    for i in range(len(key)):
        cipher_dict[key[i]] = cipher[i]
    return cipher_dict

def cipher(string,code_dict):

    coded_list = []
    list_string = list(string)
    list_string = [ord(i) for i in list_string]
    for i in list_string:
        coded_list.append(code_dict[i])
    coded_list = [chr(i) for i in coded_list]
    return  ''.join(coded_list)

msg = 'HelloWorld2017'
encode_dict = create_cipher()
decode_dict = {y:x for x,y in encode_dict.iteritems()}
encoded_cipher = cipher(msg,encode_dict)
decoded_cipher = cipher(encoded_cipher,decode_dict)

print msg
print encoded_cipher
print decoded_cipher


>>>
HelloWorld2017
pryyLILoyx9fgm
HelloWorld2017

3 个答案:

答案 0 :(得分:0)

您正在调用类中属性的部分中调用方法...这里有一些选项,具体取决于您需要执行的操作。

  1. 创建一个构造函数并在那里调用它。
  2. 为ABC.methodName分配内容,例如:private DFG = ABC.methodname();
  3. 也许,创建一个调用ABC.methodname()
  4. 的Main方法

答案 1 :(得分:0)

您有一个类ABC,其方法为methodname(),您想从另一个类调用该方法。

因此,您必须在main方法中执行对象初始化等功能,例如:

public static void main(String[] args) {
    ABC method = new ABC();
}

答案 2 :(得分:-1)

再次查看您的com.sports.jump.laptop.batch.dao.PlayerCatchBallVO课程的代码。你确定methodName是一个函数,而不是一个字段吗?