interface flower{ void setname(String name); void setcolor(String color); void setcountry(String country); void setplace(String place); String getname; String getcolor; String getcountry; String getplace; } class flowers implements flower{ private String name; private String color; private String country; private String place; public void setname(String name){ this.name=name; } public void setcolor(String color){ this.color=color; } public void setcountry(String country){ this.country=country; } public void setplace(String place){ this.place=place; } public String getname(String name){ return name; } public String getcolor(String color){ return color; } public String getcountry(String country){ return country; } public String getplace(String place){ return place; } } public String flowerstest(){ String infor="花的名称是:"+name+"; "+"花的颜色是:"+color+";"+" 花的国家是:"+country+"; 花的产地是:"+place; return infor; } public class flowerlearn{ public static void main(String[] args){ flowers a=new flowers(); flowers b=new flowers(); a.name="牡丹"; a.color="红色"; a.country="中国"; a.place="沈阳"; b.name="玫瑰"; b.color="红色"; b.country="美国"; b.place="拉斯维加斯"; System.out.println(a.flowerstest()); System.out.println(b.flowerstest()); } }
3条回答 默认 最新
- weixin_32773751 2015-11-14 15:06关注
flowers类括号不匹配,有一个方法写到类外面去了
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
- ¥500 52810做蓝牙接受端
- ¥15 基于PLC的三轴机械手程序
- ¥15 多址通信方式的抗噪声性能和系统容量对比
- ¥15 winform的chart曲线生成时有凸起
- ¥15 msix packaging tool打包问题
- ¥15 finalshell节点的搭建代码和那个端口代码教程
- ¥15 Centos / PETSc / PETGEM
- ¥15 centos7.9 IPv6端口telnet和端口监控问题
- ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作