类的无参方法
类的方法由哪几部分组成?
方法的定义:
1.访问权限修饰符 2.方法返回的数据类型 3.方法的名称 4.方法的主体 成员变量和局部变量的区别有那些? ~ 作用域不同
- 成员变量的作用域在整个类内部都是可见的
- 局部变量的作用域仅限于定义它的方法 ~ 初始值不同 - Java 会给成员变量一个初始值
- Java 不会给局部变量赋予初始值 ~ 在同一个方法中,不允许有同名局部变量;
在不同的方法中,可以有同名局部变量 ~ 两类变量同名时,局部变量具有更高的优先级 如何定义类的方法
类的方法定义类的某种行为 (或功能)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgIAAACACAIAAAD2wJZhAAARvElEQVR4nO2dT2gc1x3H39E3Qy+BHhpfqpzsyziBhaCDC4HkUOjJhYEWDEsuDcYppJRCMoS2lB42J7c9tL1MaA6iVHhtJ3JQFMTUSsC1kxhLW2PFjb2r9dqOPLtG3s1alnqYf2/evPnz5s/Om9H3w+9g1juzb+e9+X3ev1mRfQAAAAcYUnYBAAAAlAk0AAAABxpoAAAADjTQAAAAHGigAQAAONBAA0A6Hk333tkYzxsjsmgissS8MTp9/Ul/sld2lQKpgQaAXKw8eDq3PHxz/f7CoN/d7SKyxMKgr90czC0PLw6mZVcskBdoAEhEf7J3dMVcG/VKT6B1ivVx7+iKufH4WdnVCyQFGgAScfr6E+3moPS8Wb84e+feySs7ZVcvkBRoAEjEsZXh0vZW6UmzfrE+7h2+YJZdvUBSoAEgEWTRLD1j1jXIIjQA+EADQCLy1oChNQghhDR14WPbKiGEEFXn/a/RUgghpKEZ9iu69W6lZeRREl21T24fFX5aaADkADQAJCL/0YCdzRWtE/6ejqYQ4k/rzoH0K1ToTX92jnQGTxshqd+P2rIKFnpaaADkAjQAJKK8SSGnt+5m6igNWG/21GJZwQfd63c1w0NtcwRjv9gOqiHaJdAASAM0ACQiswY4feqw9Bs128PD6vsH36C0NM6HuhqwHNDQtGbgRd4YhdYAM+ZghyDQAMgJaABIRJ6jgchZneA4gOmVhx1uaYCjBOed9otNnX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SYVu6iT0U7ih8PZiMhEyGoiD6eX5UrPvDOymHecV/5Ks90WcDQMu9v4iFt7jY/6W57s43gJUwm+XuuUlkcG5z3trnYeiwWw6FGuW8kwg8Fp7khkAr65Trzbz6i5FRTDxt0tfiwogXWKZUYYJmejj39pxKYguFDUFxBsd1ksDutpQlAxzl3UMQ2sEH+bK4xJ5PyqX+KPziNiWFy2D2T83IM8EAm1u37PcUeV3Oittr7uQ19pAdiKeG/jRbz7lCiBFDfquBjJMMRUqw28KISoTCVtemAxmrAF5JhC8T2QX/8MKH9wUYPBWmPKvu+RwNfCatrp0tZ9XDSJmU6HQAEIghFpeUAaz1IA8EwgRRuF8RMwCGP0VxB4gKFoDSQQgVIOImVVolAaevzTEn41GuLE57R1qD0VbGC2DGWoAEwhsFKeB5AKwQGLJHuluxjCiNHDyys7ZO/dK/8IISWJh0J83RunamSWDKvymUG2jCA2ICsACiSV7ZLkZg0Rp4Jq5e3zV3JzC24hud7d74vKjDwdPs7S2FH+pKgg0kC5y10Dq2kRiyR7Zb0aaKA3s7++3bo2Pr5oLg37pXxtRYixtb524/OjtjRz68tmBBtKFPH+LeB+JJUMUcTPGaGB/f39te3feGJFFE3Fg49jKMMeuR0YINJAqiEwa2EdikelmjNcAAFIBDdRDA0AeoAFQMaABaADkCzQAKgY0AA2AfIEGQMWABqABkC/QAKgYh9pD7DWEBkCOQAOgYuAZVGgA5As0ACrGS6ujcw+x31wsru1sPfdRbr89AGoGNAAqxq/Wx7/u3C89sVYrzt65d/LKTtlVByQFGgAVY2179/gqVonF4tXPtv+1NS276oCkQAOgerz+5ZM/bGJAkDTe7997Ze1x2ZUG5AUaANVj/Gx/bhkLxYlifdybWx72J3tlVxqQF2gAVJKVB0+Pr5rXdrZKz7Myx/q49+pn2//ofld2dQGp+T9m4T499n9GVwAAAABJRU5ErkJggg==" alt="" />
语法 : 定义类的方法:
//步骤1: 定义方法名以及 返回值类型
public 返回值类型 方法名(){
//步骤2: 编写方法体
// 这里编写方法的主体
} 方法的返回值 两种情况: 如果方法具有返回值,方法中必须使用关键字 return 返回该值, 返回值类型为该返回值的类型。 语法: return 表达式: 作用: 跳出方法,返回结果 如果方法没有返回值,返回值类型为: void 方法调用 方法是个 "黑匣子" , 完成某个特定的应用程序功能,并返回结果 方法调用:执行方法中包含的语句 语法: 对象名.方法名(); 方法调用小结: 方法之间允许相互调用,不需要知道方法的具体实现,实现重用,提高效率
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkEAAADYCAIAAABjkKBYAAAgAElEQVR4nO2dz2tkTVfH79KlCxcK/hEDacJkdoIILlyZXaBpYhwRFR5EBkSRQNCGQGB4F8FtBqQRehFInFcGX3iMKPSgb0OGIYtn8zAgjNllMfPykGTaxf11qupU1al7695b3fk2H4ZJ9/1Zt6q+91SdcypbrVa/9cc//40/+ddf/9N3AIDB+e2Df0F7BEBItlqtfvPlz3/tL36Rffc9AGBw0B4BCAAaBkBSoD0CEAA0DICkQHsEIABoGABJgfYIQADQMACSAu0RgACgYf3z8nq1uv5ofP/+9efVD+/eD355YFjQHmPz8e3q9iX58+Wb/k7d47meKtCw/klAw96//ly36hfvvqwsn7dogb2D9tiaj29p1X1zuzL+5BpgBxz/+IPvXJbeAIiBhvUPqbUf39rUo9Nmljfjzz++qP+kL6rfZ98VzQ8a1j9oj2158+MPn1er1ZfXx/k3719/rmv7y2tS8zvmxbsvq9XtS6OZ01dVaFhboGH9k4Adpr6NQsNSAu0xAqoB9OLdbaFnvdbqj2+Va/hCtbOSUmhYW6BhfZLX49fXq9X1j7livby2WWHVW2SXF5NLFzQsJdAeu6NPI0wbw9S0qvoTGtYWaFif5PU1/1d7LxvSpwMalhJojy14//qzY3Te+HSoZ8X4YdmC9Nb94t0XaFgcoGE98r62vepBPNenJwmBhqUE2mMsXrz7ooxnHP/4w6qn18TKT6poQfnYJmnX0LBoQMN6pHCXSq3Wwi8xKdAe4/DmdlUqVtXi8qreea0uTv3x9efiXPW4/Xcf366+vD6GhsUDGtYfx+9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jQMgLRAewRADjQMgLRg2yOcjwBggYYBkBZODUMaJwAUoGEApIW9PTbNIA7A5gINAyAtPHlzYixiAsDGAA0DIC2gYQDIgYYBkBbQMADkQMMASAvfOhLIRANADTQMgLRwtsd86QZ4dgBQAA0DIC3c7bFwsoeGAXB3fwsNAyA1vGOJCBEDoAIaBkBaeHw6kKoDAAI0DIC0gF8iAHKgYQCkBTQMADnQMADSAhoGgBxoGABp4cmXCA0DgAANAyAt3Hnr4VUPAAUaBkBauDQMRhgAKtAwANIC7REAOdAwANIC7REAOf8P7uuygjHfM88AAAAASUVORK5CYII=" alt="" />
常见错误:
1. 方法的返回值类型为: void, 方法中不能有return 返回值!
2. 方法不能返回多个值。 只能是唯一的一个值 !
3 .多个方法不能相互嵌套定义 !
4.不能在方法外部直接写程序逻辑代码 ! 备注: 成员变量和局部变量的区别 作用域不同
局部变量的作用域仅限于定义它的方法
成员变量的作用域在整个类内部都是可见的
初始值不同
java 会给成员变量一个初始值
java 不会给局部变量赋予初始值 注意:
在同一个方法中,不允许有同名局部变量
在不同的方法中,可以有同名局部变量 在同一个类中,成员变量和局部变量同名时,局部变量具有更高的优先级。 常见错误:
局部变量 avg 的作用域仅限于 calcAvg()方法 总结:
定义类的方法必须包括以下三个部分
方法的名称
方法返回值的类型
方法的主体
类的方法调用,使用如下两种形式
同一个类中的方法,直接使用 “方法名()”调用
不同类的方法,首先创建对象,再使用
"对象名.方法名()" 来调用
在 Java 中,有成员变量和局部变量,他们的作用域各不相同
Java Doc注释以 "/** 开头,以 */ 结尾" !