# Learn Solidity Series 3: constructor **Published by:** [cova](https://paragraph.com/@cova/) **Published on:** 2022-03-18 **URL:** https://paragraph.com/@cova/learn-solidity-series-3-constructor ## Content Learn Solidity SeriesLearn Solidity SeriesBefore Solidity 0.4.22默认构造方法与Java类似,如果未指定会采用默认的构造方法。当然,也可以明确指定构造方法。通过function指定了Solidity的构造方法,同时也可以像Java一样,给构造方法指定参数,但无法像Java那样创建多个重载的构造方法。pragma solidity ^0.4.21; contract DemoTest{ function DemoTest() public{ } } After Solidity 0.4.22使用constructor来定义构造函数pragma solidity ^0.4.22; contract DemoTest{ constructor() public{ } } ## Publication Information - [cova](https://paragraph.com/@cova/): Publication homepage - [All Posts](https://paragraph.com/@cova/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@cova): Subscribe to updates