function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
davcondevdavcondev 

dependentPicklistSample error: no viable alternative at character '%'

I have copied the Bitset class from the dependent picklist sample code (bottom of page) into an extension class.

 

I get the error on the line indicated below.

 

  class Bitset {
    byte[] data;
    
    public Bitset(byte[] data) {
      this.data = data == null ? new byte[0] : data;
    }
    
    public boolean testBit(int n) {
      return (data[n >> 3] & (0x80 >> n % 8)) != 0; //error reported on this line
    }
    
    public int size() {
      return data.length * 8;
    }
  }

 

Any ideas as to what could be wrong?

 

FYI I'm looking at this code because I have a requirement to conditionally display dependent picklist values in a table  instead of using the standard selectLists.

davcondevdavcondev

Oops just noticed that's java code...

 

Looks like to use this in an controller I would need to figure out apex equivalents for byte, %, etc

 

Anyone done this before?

 

hchhch

You have to use  "math.mod(i, j)" instead of i%j.