使用Java,我试图使用整数ID变量来访问包,以获得名为" test.company1"的包。和" test.company2"。然后我想创建一个名为" Products"的类的对象。这是在两个包中。什么是最好的方式?
Package pkg = Package.getPackage("test.company"+companyId);
Class company1 = pkg.getClass("Products");
//to then be able to do something like
//test.company1.Products products = new test.company1.Products();
//and test.company2.Products products = new test.company2.Products();