0

I have this:

package org.ores;
public class Asyncc {

    public static Class<Queue> Queue = new Class<Queue>();
}

but I get:

'Class(java.lang.ClassLoader, java.lang.Class)' has private access in 'java.lang.Class'

the Queue class looks like:

package org.ores;

public class Queue {

  public Queue(){

  }
}

it's in the same package but in a different file. My question is - is there a way to export the Queue class from the Asyncc class? Putting a ref to the Queue class as a static field on Asyncc?

khmarbaise
  • 92,914
  • 28
  • 189
  • 235

1 Answers1

3

(Of course!) The constructor new Class() is forbidden/private :) , what you want is "just":

public static Class<Queue> queueClass = Queue.class;

see: How does a '.class' property work? or What does .class mean in Java?

xerx593
  • 12,237
  • 5
  • 33
  • 64
  • ...you "construct" the class by writing, compiling and loading it (to the class loader), from then on you cannot construct it, but refer to it'(s only instance) with the `.class` "keyword"/property. – xerx593 Feb 02 '19 at 22:14