void add(int,int);
void add(int ,float);
void add(float,int);
unsigned int i = 10;
unsigned float j = 1.0;
add(i,f); // ambiguios call error
Run Code Online (Sandbox Code Playgroud)
如果我从程序中删除unsigned,那么它工作正常.
int i = 10;
float j = 1.0;
add(i,f); // working
Run Code Online (Sandbox Code Playgroud)
为什么在重载函数中使用无符号变量会导致ambiguios调用
我使用内部类的层次结构来表示应用程序中的一些数据,我遇到了一个我根本不理解的错误消息.我的代码可以归结为以下最小的例子:
public class A {
public class B extends A {}
public class C extends B {}
}
Run Code Online (Sandbox Code Playgroud)
Javac(当然我的IDE)无法使用以下错误消息编译代码:
A.java:3: cannot reference this before supertype constructor has been called
public class C extends B {}
^
1 error
Run Code Online (Sandbox Code Playgroud)
我没有写this任何地方.没有比上面提供的更多的代码,所以我假设javac生成了与内部类相关的东西.
我找到了另一种表示我的数据的方法,所以我只是对它为什么不编译的一个很好的解释感兴趣.
我目前正在尝试使用Cloudera Hadoop环境中的Encrypted Shuffle测试已实现的更改以实现安全性.
我已经创建了证书和密钥库,并将它们保存在适当的位置.
我正在测试TaskTracker的HTTPS端口50060.
当我对该端口进行卷曲时,我得到以下错误响应.
ubuntu@node2:~$ curl -v -k "https://10.0.10.90:50060"
* About to connect() to 10.0.10.90 port 50060 (#0)
* Trying 10.0.10.90... connected
* successfully set certificate verify locations:
* CAfile: none
CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Closing connection #0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Run Code Online (Sandbox Code Playgroud)
当我检查开放的ssl客户端时,我得到了以下响应
ubuntu@node2:~$ openssl s_client -connect 10.0.10.90:50060
CONNECTED(00000003)
139749924464288:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:749:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake …Run Code Online (Sandbox Code Playgroud) 如果不迭代每个元素,如何使用new创建数组并将每个元素初始化为某个值?
bool* a = new bool[100000];
Run Code Online (Sandbox Code Playgroud)
使用VS 2008.
谢谢!
实例化和启动Java线程时分配了多少内存(大致)?
这是一个代码示例:
// Definition of the thread class
class BasicThread extends Thread {
// This method is called when the thread runs
public void run() {
}
}
.
.
.
// Create and start the thread
Thread thread = new BasicThread();
thread.start();
Run Code Online (Sandbox Code Playgroud) 例如,以下是语法正确的代码
Double number = 10.0;
Run Code Online (Sandbox Code Playgroud)
是否可以定义我自己的类,如Price
Price myPrice = 10.0;
Run Code Online (Sandbox Code Playgroud)
实际编译?
我在教科书中找到了关于集合和泛型的章节.
这句话是
"由于泛型类中的对象类型受到限制,因此可以在不进行转换的情况下访问元素."
简单来说,有人可以解释这句话的含义吗?
虽然我知道 Re-EntrantLocks 和 之间的理论差异synchronized,但我对以下几点感到困惑。
从一篇关于 Javarevisited比较synchronized和Lock对象的文章中看到这个声明:
Java 中 ReentrantLock 和 synchronized 关键字之间还有一个值得注意的区别是,在等待 Lock 时可以中断 Thread 的能力。在synchronized关键字的情况下,线程可能会被阻塞等待锁定,无限期并且无法控制。ReentrantLock 提供了一个叫做 lockInterruptably() 的方法,可以用来在线程等待锁的时候中断它。类似地,如果锁定在特定时间段内不可用,则可以使用带超时的 tryLock() 超时。
根据上述声明,我确实尝试在同步方法(即阻塞等待)上中断线程等待(),但它确实抛出了 InterruptedException。但这种行为与上述声明中的内容相矛盾。
// this method is called from inside run() method of every thread.
public synchronized int getCount() {
count++;
try {
Thread.sleep(3000);
System.out.println(Thread.currentThread().getName() + " gets " + count);
} catch (InterruptedException e) {
e.printStackTrace();
}
return count;
}
....
....
t1.start();
t2.start();
t3.start();
t4.start();
t2.interrupt();
Run Code Online (Sandbox Code Playgroud)
这是我得到的输出:
Thread 1 gets 1 …Run Code Online (Sandbox Code Playgroud) java ×7
c++ ×2
arrays ×1
cloudera ×1
constructor ×1
function ×1
generics ×1
hadoop ×1
html ×1
inheritance ×1
new-operator ×1
openssl ×1
preprocessor ×1
return ×1
return-value ×1
ssi ×1
ssl ×1
stack ×1