Java storing long value in place of user defined class

in c++, we can store a long value in place of a user defined pointer. as follows:

class p1{
   int val=0;
};
    
int main()
{
  p1* p = new p1();
  p = (p1*)(void*)546L;
  cout<<(long)p; // prints long value 546
    
  return 0;
}

is there any way to do the same thing in Java?