“无效的声明方法”在java中 [英] "Invalid declaration method" in java
本文介绍了“无效的声明方法”在java中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class Bugs{
private String bugType;
private int legs;
private int arms;
private String nativeTo;
public bug(String bt, int l, int a, String nt){
bt=bugType;
l=legs;
a=arms;
nt=nativeTo;
}
}
为什么我得到一个无效的声明方法这里?
Why do I keep getting a "invalid declaration method" here? It keeps saying a return method is needed.
推荐答案
您的构造函数必须与您的类命名相同。错误,而不是错误。你基本上声明一个没有返回类型的方法是什么是非法的。
Your constructor must be named the same as your class. Bugs, not bug. You are basically declaring a method without return type what is illegal.
这篇关于“无效的声明方法”在java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文