How to use arrays in Solidity programming language ?

How to use arrays in Solidity programming language ? 

How to use arrays i.e static array,dynamic array in Solidity programming language 


 pragma solidity ^0.5.0;


contract test {

   function testArray() public pure{

      uint len = 7; 

      

      //dynamic array

      uint[] memory a = new uint[](7);

      

      //bytes is same as byte[]

      bytes memory b = new bytes(len);

      

      assert(a.length == 7);

      assert(b.length == len);

      

      //access array variable

      a[6] = 8;

      

      //test array variable

      assert(a[6] == 8);

      

      //static array

      uint[3] memory c = [uint(1) , 2, 3];

      assert(c.length == 3);

   }

}

Comments

Last 7 Days

How to use referrerpolicy Attribute value ( strict-origin-when-cross-origin ) with < iframe > tag in HTML ? with example

How to use sandbox attribute value ( allow-top-navigation) with < iframe > tag in HTML ? with example

How to use referrerpolicy Attribute value ( unsafe-url ) with < iframe > tag in HTML ? with example

Write a program in HTML to create a Web page insert and image background ?