Java与C++的多态
没有必要用一堆绕口的形容词来描述什么叫多态,只举出几个关键点。
设:gun为父类,shootgun和pistol为gun的子类。
Java:
class gun {
void shoot() {
System.out.println("gun shoot");
}
}
class shootgun extends gun {
void shoot() {
System.out.println("shootgun shoot");
}
}
class pistol extends gun {
void shoot() {
System.out.println("pistol shoot");
}
}
C++:
class gun
{
void shoot()
{
cout << "gun shoot" << endl;
}
};
class shootgun : gun
{
void shoot()
{
cout << "shootgun shoot" << endl;
}
};
class pistol : gun
{
void shoot()
{
cout << "pistol shoot" << endl;
&n
相关文档:
http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html
Sunday, May 10, 2009
Hadoop should target C++/LLVM, not Java (because of watts)
< type="text/javascript">
digg_url="http://www.trendcaller.com/2009/05/hadoop-should-target-cllvm-not-java.html";
Over the years, ......
//=============================输出奇数
public class OddTest {
public static boolean isOdd(int i){
return i % 2 != 0; //比较 i % 2 == 0;注: -1%2 = -1
}
public static void main(String[] args) {
for(int i = -10; i <= 10; i++) {
System.out.println(isOdd(i));
}
}
}
// ......
1、创建了一个对象后:
(1)没有在适当的地方释放掉
(2)在应该释放的地方没有做释放操作
例如:下面一段程序:
m_progressDlg = ProgressDialog.show(this, getString(R.string.market),getString(R.string.is_visiting), true);
new Thread() {
public v ......
//从数组a中删除数组b中存在的元素
String stra[] = {"g","b","c","h","k"};//原始数组
String strb[] = {"g","k"}; //移除的元素
ArrayList list = new ArrayList();
//方法一
for(int i=0;i<stra.length;i++){
int n=0;
......
public class EchoDefaultSystemEncoding
{
public static void main(String[] args)
{
String encoding = System.getProperty("file.encoding");
System ......