Writing matrix in Julia

I wanted to write matrix for the total coin angular momentum with the following code

mvalues = -j:1:j

cardinality = length(mvalues)

Jminus is zero except for directly above the diagonal

There is an implicit \hbar & square root

Jminus = zeros(cardinality)

for i=2:cardinality
m = mvalues[i]
Jminus[i-1, i] = sqrt(j*(j+1)-m*(m-1))
After compiling, I am getting the following error
BoundsError: attempt to access 9-element Vector{Float64} at index [1, 2]

I am new to Julia, therefore any suggestion would be very helpful.

Jminus = zeros(cardinality) creates a vector of length cardinality. Maybe you want Jminus = zeros(cardinality, cardinality) for a square matrix?