interface ComputerCompany {
//该接口有2个功能:String computerName,void printFunction。
public String computerName ();
public void printFunction();
}
interface ComputerWeight {
//该接口中有3个功能:double computrWeight,void printName,double printPrice。
double computrWeight();
void printName();
double printPrice();
}
public class FlashMemory implements ComputerCompany {
double computrWeight(){
double i = 1.33;
if (i>2)
{
return 1.0;
}
else
{
return 2.0;
}
}
public String computerName (){
String s ="sd";
return s;
};
public void printFunction(){
System.out.println("这是训练接口使用的代码");
};
}
接下来是测试用的代码
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
FlashMemory f = new FlashMemory();
System.out.println(f.computerName());
System.out.println(f.computrWeight());
f.printFunction();
}
}