小弟初学java和android,在一个android的程序中看到这样一段代码public interface IImage {
       public abstract Bitmap fullSizeBitmap(int minSideLength,
            int maxNumberOfPixels);
    public abstract Bitmap fullSizeBitmap(int minSideLength,
            int maxNumberOfPixels, boolean rotateAsNeeded);
    public abstract Bitmap fullSizeBitmap(int minSideLength,
            int maxNumberOfPixels, boolean rotateAsNeeded, boolean useNative);    }
public class CropImage extends MonitoredActivity {private IImage mImage;final Bitmap b = (mImage != null)
? mImage.fullSizeBitmap(IImage.UNCONSTRAINED,
1024 * 1024)
: mBitmap;
.........
}这个接口在这为啥能这么用呢?不是说接口不能实例化的吗?哪位大神能给我分析一下

解决方案 »

  1.   

    所谓接口不能实例化是指:
        private IImage mImage = new IImage();
    但是如果ArrayList 实现了 List接口,就可以这样写:
    List list = new ArrayList();
    或者
    List list;
    list = new ArrayList();
      

  2.   

    所谓实例化不是声明,而是构造新对象,
    通俗点,一般说 
    Object object 是声明
    new Object()才是实例化
      

  3.   

    大家有人用过java调用extmail的userctl.pl脚本 往extmail中添加用户吗,我自己写了代码执行了 但是不会向extmail中插入数据.我的代码如下
    String comm = "perl /var/www/extsuite/extman/tools/userctl.pl--mod=add -username="+uname +"-password="+pass;
    runLinuxCmd(String cmd) //本类调用public String runLinuxCmd(String cmd) {
    BufferedReader bf = null;
    try {
    Process process = Runtime.getRuntime().exec(cmd);
    bf = new BufferedReader(new InputStreamReader(process.getInputStream()));
    String line = "";
    String resutl="";
    while ((line = bf.readLine()) != null) {
    resutl =resutl+ line.trim()+"\n";
    }
    System.out.println("---------------try result------------------"+resutl);
    return resutl;
    } catch (java.io.IOException e) {
    e.printStackTrace();
    System.out.println("------------error--------------");
    return null;
    } finally {
    if (bf != null) {
    try {
    bf.close();
    bf = null;
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }
    }}单独在shell环境下执行perl命令是没有问题,能够插入数据。 我在网上看到有人讲过把perl命令写进sh脚本就可以了,我也不知道这是为什么按理说java能够调用shell命令也能调用perl脚本命令。非要包装一下的话我也写了一个shell脚本单独运行shell脚本也能添加数据就是java调用又没有添加数据了 我想要的是验证过的结果 大道理就不用讲了直接来真工夫啊 我写的shell脚本代码如下:#!/bin/sh
    perl /var/www/extsuite/extman/tools/userctl.pl--mod=add -username="$1" -password="$2";这个做了两天都没有做好 如果能有满意的结果我会加分的谢谢大家 欢迎大家来这里回帖http://topic.csdn.net/u/20110821/20/ae1e4815-1c81-4c75-88ae-db263128f963.html?61772
      

  4.   

    这个IImage,类似于java中的list。lz这样应该明白了吧