再看Java基础 - 换个方式看Java ~ 1
2021/12/28 17:09:57
本文主要是介绍再看Java基础 - 换个方式看Java ~ 1,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
class MakeMoney: highSchoolDegree = '' knowledgeReserves = '' personalQualities = '' strongHeart = '' def __init__(self,highSchoolDegree,knowledgeReserves): self.highSchoolDegree = highSchoolDegree self.knowledgeReserves = knowledgeReserves def __str__(self): return "MakeMoney needed: highSchoolDegree: %s,\t knowledgeReserves: %s " % ( self.highSchoolDegree, self.knowledgeReserves) def printGoal(): mm = MakeMoney('本科', '计算机') print(mm) if __name__ == '__main__': printGoal()
同样MakeMoney,python相对来说是这样做的
但是奇怪的是,如果将python的变量注释掉,同样可以得到相同的结果
class MakeMoney: def __init__(self, highSchoolDegree, knowledgeReserves): self.highSchoolDegree = highSchoolDegree self.knowledgeReserves = knowledgeReserves def __str__(self): return "MakeMoney needed: highSchoolDegree: %s,\t knowledgeReserves: %s " % ( self.highSchoolDegree, self.knowledgeReserves) def printGoal(): mm = MakeMoney('本科', '计算机') print(mm) if __name__ == '__main__': printGoal()
结果
MakeMoney needed: highSchoolDegree: 本科, knowledgeReserves: 计算机
同样的事情放在.java文件中就不可能通过编译了
这篇关于再看Java基础 - 换个方式看Java ~ 1的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-02Java管理系统项目实战入门教程
- 2024-11-02Java监控系统项目实战教程
- 2024-11-02Java就业项目项目实战:从入门到初级工程师的必备技能
- 2024-11-02Java全端项目实战入门教程
- 2024-11-02Java全栈项目实战:从入门到初级应用
- 2024-11-02Java日志系统项目实战:初学者完全指南
- 2024-11-02Java微服务系统项目实战入门教程
- 2024-11-02Java微服务项目实战:新手入门指南
- 2024-11-02Java项目实战:新手入门教程
- 2024-11-02Java小程序项目实战:从入门到简单应用