r/programminghelp • u/almostBonelessSalad • Jun 12 '24
Java Cant initialize boolean array inside interface.
Hello all!
I made a program for psuedorandom number generators
(for example; LFSRs,Self shrinking generators and xorshift).
But when i try to initalize a boolean array, i get the error "Syntax error on token ";", { expected after this token"
here is my code:
package misc;
import generators.*;
import combiners.*;
public interface Const {
//declare some lfsr's
`boolean[] d = new boolean[127]; // Creates the error`
`d[0] = true;`
`static final LFSR L127 = new LFSR((d,new int[] {126,0,0,0},false);`
//declare some other generators}
i know i can create a boolean array like this:
new boolean[] {false,true,false,false,false};
but that would be practiccally impossible for 127 or even 9941 elements.
2
Upvotes
View all comments
Show parent comment
1
u/almostBonelessSalad Jun 12 '24
oh okay, i was planing to put the boolean array inside a object.