类中的方法—-》做一件事情 []括起来的部分可以没有
权限修饰符 [特征修饰符] 返回值类型 方法名字 (参数列表) [抛出的异常] [
{ 方法体 }
]
无参数无返回值
public class Index{
public void test(){
}
}
无参数有返回值
public class Index{
public String test(){
return "返回值"
}
}
有参数无返回值
public class Index{
// 参数可以有多个
public void test(String type, int count){
System.out.print(type);
System.out.print(count);
}
}
有参数有返回值
public class Index{
public String test(String type){
return type;
}
}