Java????????????????????
???????????? ???????[ 2013/1/25 9:45:48 ] ????????
???????java?е?????????????????????
//??????
public abstract class AExample
{
public abstract int add(int x??int y);
public abstract int sub(int x??int y);
}
//???
public interface IExample
{
public int add(int x??int y);
public int sub(int x??int y);
}
??????????÷??????????????????????????????????????????????????ж????????????????????????е????????????
????1?????????????????
public class MyClass extends AExample
{
//??????????壺??
//?????????е??????
public int add(int x??int y)
{
return x+y;
}
public int sub(int x??int y)
{
return x-y;
}
//???????????
}
??????÷?????
AExample ae = new MyClass();
int s = ae.add(4??2);
int t = ae.sub(4??2);
????2??????????????
public class MyClass implements IExample
{
//??????????壺??
//?????????е??????
public int add(int x??int y)
{
return x+y;
}
public int sub(int x??int y)
{
return x-y;
}
//???????????
}
??????÷?????
IExample ae = new MyClass();
int s = ae.add(4??2);
int t = ae.sub(4??2);
??????????????????????????÷??????????????
??????????????????
?????????????????????????????????y????????????????
????1?????????????????????????
????int[] array;
?????????????????array????????????array[0]??array[1]?????????????????????????????????????
????int[] array = new int[]{1??2};
????1??2???????????????“??????”?????array[0]??array[1]???????????array????????
????2?????????????????????????????
AExample ae = new AExample(){
public int add(int x??int y)
{
return x+y;
}
public int sub(int x??int y)
{
return x-y;
}
}??
int s = ae.add(4??2);
int t = ae.sub(4??2);