首页
\
问答
\
为什么我不能导入java.util.concurrent.ConcurrentSkipListMap(Why can't I import java.util.concurrent.ConcurrentSkipListMap)
为什么我不能导入java.util.concurrent.ConcurrentSkipListMap(Why can't I import java.util.concurrent.ConcurrentSkipListMap)
这是我的代码:
package DavidPackages.Other; import java.util.concurrent.ConcurrentSkipListMap; public class SkipListTest { }
这是我得到的错误:
cannot find symbol class ConcurrentSkipListMap
有任何想法吗?
Here is my code:
package DavidPackages.Other; import java.util.concurrent.ConcurrentSkipListMap; public class SkipListTest { }
Here is the error I get:
cannot find symbol class ConcurrentSkipListMap
Any ideas?
原文:https://stackoverflow.com/questions/10957882
更新时间:2023-08-15 12:08
最满意答案
使用
std::function
class Test { std::function<void()> func; public: Test(const std::function<void()> &func) : func(func) {} void do_something() { func(); } }; void my_func() { std::cout << "Hello" << std::endl; } int main() { Test test(my_func); test.do_something(); }
基于模板
template <typename Func> class Test { Func *func; public: Test(const Func &func) : func(func) {} void do_something() { func(); } }; void my_func() { std::cout << "Hello" << std::endl; } int main() { Test<void()> test(my_func); // Test<decltype(my_func)> test(my_func); // This is even better test.do_something(); }
Using
std::function
class Test { std::function<void()> func; public: Test(const std::function<void()> &func) : func(func) {} void do_something() { func(); } }; void my_func() { std::cout << "Hello" << std::endl; } int main() { Test test(my_func); test.do_something(); }
Template based
template <typename Func> class Test { Func *func; public: Test(const Func &func) : func(func) {} void do_something() { func(); } }; void my_func() { std::cout << "Hello" << std::endl; } int main() { Test<void()> test(my_func); // Test<decltype(my_func)> test(my_func); // This is even better test.do_something(); }
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
将函数转换为OO方法(Convert a function to an OO method)[2023-02-14]
public function get_menu(){ global $session; $user_status = $session->power; $adminMenus =$this->admin_menu; // associate array($key => value) if($user_status == 'admin') { foreach($adminMenus as $key => $value): { ... -
您需要创建一个Scheduler实例。 x = Scheduler() 代替 x = Scheduler You need to create an instance of Scheduler. x = Scheduler() instead of x = Scheduler
-
1)是的,这是正确的。 子类继承父级的任何protected或public属性和方法。 任何声明为private都不能使用。 2)这是真的。 只要该类被加载(这与以前的自动加载问题一致),您可以通过作用域解析运算符(::)访问静态方法,如下所示: ClassName::methodName(); 3)你的public有意义是正确的,但正如我前面提到的那样, private方法只能由它们声明的类使用。 class parentClass { private $x; public $y; } ...
-
使用std::function class Test { std::function
func; public: Test(const std::function &func) : func(func) {} void do_something() { func(); } }; void my_func() { std::cout << "Hello" << std::endl; } int main() ... -
对于静态方法: set_error_handler(array('CallbackClass', 'StaticMethod')); 对于非静态方法: $obj = new CallbackClass(); set_error_handler(array($obj, 'Method')); For static methods: set_error_handler(array('CallbackClass', 'StaticMethod')); For non-static methods: $obj = ...
-
您可以定义一个类似于TopClass实现的TopClass的接口 。 这将允许中产阶级知道实现接口的东西存在,但不能直接知道TopClass是什么。 然后,为了消除每次传递引用的需要, Middleclass可以保存对通过构造函数传入的IDoesWhatTopClassDoes实例的成员引用。 You could define an interface like IDoesWhatTopClassDoes which the TopClass implements. This will allow the ...
-
您不需要再次设置它们,它们已经存在于实例中: class Monster(object): def __init__(self, health, name): print(name + " has been born!") self.name = name self.health = health self.stats() def stats(self): print(self.name + " - ...
-
如果必须使用call ,只需在“this”参数后面传递参数: interactiveElement.prototype.moveTowards.call(this, target); //how do I pass target 但如果它实际上是一个继承的方法,你可以简化它: this.moveTowards(target); 如果moveTowards在projectile原型链中的任何地方,您可以通过它访问它而不是使用...prototype...call 。 如果你有原型继承,你通常只使用call ...