dragonsun00000 2017-11-23 14:53
浏览 65

Go中Java静态属性的等效性

class Array {
    public static int MAX_SIZE = 42;
}
Array arr = new Array();
int size = Array.MAX_SIZE;

So, we can create an object of class Array, and we also have a property of class Array. What will be the equivalence of this code in Go?

  • 写回答

3条回答 默认 最新

  • douxueke5653 2017-11-23 14:56
    关注

    Go has no classes. Go has no static variables. So there is no equivalent.

    The closest concepts Go has are package constants, and struct fields. Neither is exactly the same as what you're looking for.

    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突