中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

手機wap網(wǎng)站的分析網(wǎng)絡(luò)營銷官網(wǎng)

手機wap網(wǎng)站的分析,網(wǎng)絡(luò)營銷官網(wǎng),ssh做的網(wǎng)站,網(wǎng)站代碼圖片1.static 修飾符應(yīng)用范圍 static修飾符只能用來修飾類中定義的成員變量、成員方法、代碼塊以及內(nèi)部類(內(nèi)部類有專門章節(jié)進行講解)。 2.static 修飾成員變量 static 修飾的成員變量稱之為類變量。屬于該類所有成員共享。 示例 package cn.lyxq.test04;public class Chinese…

1.static 修飾符應(yīng)用范圍

static修飾符只能用來修飾類中定義的成員變量、成員方法、代碼塊以及內(nèi)部類(內(nèi)部類有專門章節(jié)進行講解)。

2.static 修飾成員變量

static 修飾的成員變量稱之為類變量。屬于該類所有成員共享。

示例

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;public static String country = "中國";public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}
}
package cn.lyxq.test04;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp1 = new ChinesePeople("張三",20);System.out.println(ChinesePeople.country);ChinesePeople.country="日本";ChinesePeople cp2 = new ChinesePeople("李四",30);System.out.println(ChinesePeople.country);ChinesePeople cp3 = new ChinesePeople("王五",32);System.out.println(ChinesePeople.country);}}

如果類變量是公開的,那么可以使用 類名.變量名 直接訪問該類變量

3.static 修飾成員方法

static 修飾的成員方法稱之為類方法,屬于該類所有成員共享。

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;private static String country = "中國";public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}//類方法public static String getCountry() {return country;}//類方法public static void setCountry(String country) {ChinesePeople.country = country;}
}
package cn.lyxq.test04;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp1 = new ChinesePeople("張三",20);ChinesePeople.setCountry("日本");ChinesePeople cp2 = new ChinesePeople("李四",30);System.out.println(ChinesePeople.getCountry());ChinesePeople cp3 = new ChinesePeople("王五",32);System.out.println(cp3.getCountry());//不是最優(yōu)訪問方式}}

如果類方法是公開的,那么可以使用 類名.方法名直接訪問該類方法。

4.static 修飾代碼塊

static 修飾的代碼塊被稱為靜態(tài)代碼塊,在JVM第一次記載該類時執(zhí)行。因此,靜態(tài)代碼代碼塊只能執(zhí)行一次,通常用于一些系統(tǒng)設(shè)置場景。

package cn.lyxq.test04;public class ChinesePeople {private String name;private  int age;//使用static修飾的成員變量稱為類變量,不會隨著成員變化而變化,屬于所有成員共享private static String country ;//static修飾的代碼塊稱為靜態(tài)代碼塊,在JVM第一次加載該類的時候執(zhí)行,只能執(zhí)行一次static{country = "中國";System.out.println("country屬性已經(jīng)被賦值");}public ChinesePeople(String name,int age){this.name = name;this.age = age;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getAge() {return age;}public void setAge(int age) {this.age = age;}//類方法public static String getCountry() {return country;}//類方法public static void setCountry(String country) {ChinesePeople.country = country;}
}
package cn.lyxq.test04.test;import  cn.lyxq.test04.ChinesePeople;public class ChinesePeopleTest {public static void main(String[] args) {ChinesePeople cp = new ChinesePeople("張三",20);}}

5.static內(nèi)存

http://www.risenshineclean.com/news/9536.html

相關(guān)文章:

  • 贛州建網(wǎng)站手機seo排名
  • 哪個網(wǎng)站可以代做軟件百度熱議
  • 織夢移動網(wǎng)站品牌傳播策劃方案
  • 空間站對接合肥建站公司seo
  • 寧波seo排名費用安卓優(yōu)化大師2021
  • 谷歌優(yōu)化軟件廊坊seo推廣
  • 網(wǎng)站開發(fā)與設(shè)計結(jié)課大作業(yè)搜索引擎優(yōu)化的步驟
  • 科技傳承安卓優(yōu)化大師歷史版本
  • 外加工訂單網(wǎng)優(yōu)化大師會員兌換碼
  • 鄭州一網(wǎng)網(wǎng)站建設(shè)新聞稿件代發(fā)平臺
  • 怎么選擇鎮(zhèn)江網(wǎng)站建設(shè)廈門網(wǎng)站制作
  • 深圳做網(wǎng)站的公司windows7優(yōu)化大師官方下載
  • wordpress必裝的插件焦作網(wǎng)站seo
  • 如何進行企業(yè)營銷型網(wǎng)站建設(shè)百度商家入駐怎么做
  • 用網(wǎng)站做CAN總線通信好嗎上海網(wǎng)絡(luò)seo優(yōu)化公司
  • app開發(fā)方案seo網(wǎng)頁的基礎(chǔ)知識
  • 網(wǎng)站開發(fā)軟件 論文 摘要簡單網(wǎng)頁制作成品免費
  • 做支付網(wǎng)站東莞seo推廣公司
  • 西安優(yōu)惠電商平臺網(wǎng)站今日國內(nèi)新聞頭條大事
  • 哪個網(wǎng)站的課件做的好處營銷技巧有哪些
  • 北京企業(yè)網(wǎng)站備案免費seo推廣軟件
  • 千里做他千百度網(wǎng)站2023年適合小學生的新聞
  • 怎樣接做網(wǎng)站的活電商代運營公司十強
  • 網(wǎng)站維護多少錢一個月泉州百度推廣咨詢
  • 網(wǎng)站備案怎么那么麻煩深圳百度推廣聯(lián)系方式
  • 個人可以做幾個網(wǎng)站嗎廊坊網(wǎng)站seo
  • 多個域名 指向同一個網(wǎng)站網(wǎng)站搭建費用
  • 一次備案多個網(wǎng)站網(wǎng)絡(luò)營銷戰(zhàn)略的內(nèi)容
  • 哪個網(wǎng)站可以做公務(wù)員題軟文營銷方法有哪些
  • 網(wǎng)站開發(fā)過程的基本環(huán)節(jié)杭州seo顧問