当前位置: 技术问答>java相关
一个接口的问题:
来源: 互联网 发布时间:2017-03-29
本文导语: interface anyone { final float PI=3.1416f; void setNumber(int nunber); int gerNumber(); } interface anyother { void setString(String strName); int getString(); } class Implementer implements anyone,anyother{ int number; String strName; public Implementer(){...
interface anyone
{
final float PI=3.1416f;
void setNumber(int nunber);
int gerNumber();
}
interface anyother
{
void setString(String strName);
int getString();
}
class Implementer implements anyone,anyother{
int number;
String strName;
public Implementer(){
}
void setNumber(int number){
this.number=number;
}
void setString(String strName){
this.strName=strName;
}
int getNumber(){
}
int gerString(){
}
}
error info:
Implementer should be declared abstract;it does not define
getString() in Implementer.
class Implementer implements anyone,anyother{ 提示這一句有錯
{
final float PI=3.1416f;
void setNumber(int nunber);
int gerNumber();
}
interface anyother
{
void setString(String strName);
int getString();
}
class Implementer implements anyone,anyother{
int number;
String strName;
public Implementer(){
}
void setNumber(int number){
this.number=number;
}
void setString(String strName){
this.strName=strName;
}
int getNumber(){
}
int gerString(){
}
}
error info:
Implementer should be declared abstract;it does not define
getString() in Implementer.
class Implementer implements anyone,anyother{ 提示這一句有錯
|
将int getString() 改为 public int getString()
将int getNumber() 改为 public int getNumber()
将int getNumber() 改为 public int getNumber()
|
下面这个没问题, 你那个程序错误很多阿。
interface anyone
{
final float PI=3.1416f;
public void setNumber(int nunber);
public int getNumber();
}
interface anyother
{
public void setString(String strName);
public String getString();
}
class Implementer implements anyone,anyother{
int number;
String strName;
public Implementer(){
}
public void setNumber(int number){
this.number=number;
}
public void setString(String strName){
this.strName=strName;
}
public int getNumber(){
return this.number;
}
public String getString(){
return this.strName;
}
}
interface anyone
{
final float PI=3.1416f;
public void setNumber(int nunber);
public int getNumber();
}
interface anyother
{
public void setString(String strName);
public String getString();
}
class Implementer implements anyone,anyother{
int number;
String strName;
public Implementer(){
}
public void setNumber(int number){
this.number=number;
}
public void setString(String strName){
this.strName=strName;
}
public int getNumber(){
return this.number;
}
public String getString(){
return this.strName;
}
}
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。