我有关HashMap的Java代码有什么问题?

时间:2018-10-18 16:15:48

标签: java

这是错误通知:

  

Library.java:13:错误:找不到符号         对于(String book:library.KeySet()){                                   ^符号:方法KeySet()位置:HashMap 1类型的变量库错误

这是代码:

import UIKit

public class EngineConfigurationA: OptionSet {

    public static let enableSun   = EngineConfigurationA(rawValue: 1 << 0)
    public static let enableFloor = EngineConfigurationA(rawValue: 1 << 1)

    public var rawValue: Int

    required public init(rawValue: RawValue) {
        self.rawValue = rawValue
    }

}


public class EngineConfigurationB: EngineConfigurationA {

    public static let enableWorldTracking              = EngineConfigurationB(rawValue: 1 << 2)
    public static let enableEnvironmentLightEstimation = EngineConfigurationB(rawValue: 1 << 3)
    public static let enableFloorLevelDetection        = EngineConfigurationB(rawValue: 1 << 4)

}

let optionsB: EngineConfigurationB = [EngineConfigurationB.enableWorldTracking, EngineConfigurationA.enableSun]

let contains = optionsB.contains(EngineConfigurationB.enableWorldTracking)

我想知道这段代码怎么了?特别是13号线?谢谢。

1 个答案:

答案 0 :(得分:0)

有一个错字,请使用keySet()代替KeySet()

 for (String book : library.keySet()) { }