<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    java初學者
    所有生命,不管在哪里度過,都具有同樣價值
    posts - 7,  comments - 5,  trackbacks - 0
    import javax.swing.*;
    import java.awt.*;
    public class GridLayoutDemo extends JFrame{
    public GridLayoutDemo()
     {
    ?super("網格布局");
    ?this.setSize(600,300);
    ?this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    public void setlayout(){
    ?FlowLayout layout = new FlowLayout();
    ?Container Contain = getContentPane();
    ?Contain.setLayout(layout);
    ?for(int i=1; i<6;i++)
    {
    ?JButton btn = new JButton("按鈕"+i);
    ?Contain.add(btn);
    ?}
    }
    public static void main(String []args )
    {
    ?GridLayoutDemo GridLay = new GridLayoutDemo();
    ?GridLay.setlayout();
    ?GridLay.show();
    }
    }
    posted @ 2006-12-21 20:04 悠揚---靖寶華 閱讀(303) | 評論 (0)編輯 收藏

    /*class Rectangle
    {//實例變量
    ?private double width;//類成員的訪問控制,不允許對象通過點符號,來直接訪問該變量,
    ?private double height;
    ?//方法
    ?public double Area()???????? //返回值類型 方法名字(){具體的實現語句;}
    ? {return width*height;} //求矩形面積
    ?public?double Perimeter()
    ? {return 2*(width+height);}//求矩形周長

    //構造函數

    ? public Rectangle(double width,double height) //用于變量的賦初值,
    ?? {
    ?? this.width=width;
    ?? this.height=height;//this關鍵字用于構造函數參數與實例變量名字相同時候.
    ?? }
    }

    public class RectangleDemo
    {
    ?public static void main(String [] args)
    ?{
    ??Rectangle rectangle1=new Rectangle(4,5); //矩形長寬賦值,
    ??System.out.println("矩形的面積是"+rectangle1.Area());
    ??System.out.println("矩形的面積是"+rectangle1.Perimeter());?
    ?}
    }*/

    posted @ 2006-10-20 21:02 悠揚---靖寶華 閱讀(258) | 評論 (0)編輯 收藏

    感謝 馬嘉楠的指點,本人對"類"和"方法"又多了一些理解,,,
    ?理解如下:
    ????????????????

    /*class Student??????????????? //生成一個類
    {
    ?public String? strname;???? //定義類的屬性
    ?public int???? intage;????? //定義類的屬性
    ?public boolean blsex;?????? //定義類的屬性
    }

    public class StudentDemo
    {
    ?public static void main(String [] args)
    ?{
    ??Student aStudent;????????? //由"Student類"定義一個變量,如同,"Sting 姓名";或者"int 年齡";因此在這個地方aStudent只是一個變量,
    ???aStudent=new Student();???? //這句中,new生成一個新的內存空間,我理解為"對象",并且將內存地址存放在aStudent變量中,
    ??
    ??aStudent.strname="董小飛";? ??//給對象屬性變量賦值
    ??aStudent.intage =22;?????????? //訪問對象的一個屬性變量,用"."運算符鏈接
    ??aStudent.blsex? =true;?????
    ??
    ??System.out.println("該學生的名字是: "+aStudent.strname);
    ??System.out.println("年齡是: "+aStudent.intage);
    ??if(aStudent.blsex)
    ?? System.out.println("性別是男");
    ??else
    ?? System.out.println("性別是女");
    ??}
    ?}*/

    可以畫一個簡單的圖表示:


    :未命名.bmp



    2006年10月15日
    ??
    ???????

    ??????

    posted @ 2006-10-15 11:58 悠揚---靖寶華 閱讀(356) | 評論 (0)編輯 收藏
    class Student
    {
    ?String strname;
    ?int???? intage;
    ?boolean blsex;
    ?//初始化類的實例變量
    ?
    ?
    ?void init(String name,int age,boolean sex)
    ?{
    ??strname=name;
    ??intage=age;
    ??blsex=sex;
    ?}?? //定義了一個方法,
    ?String getname()
    ?{
    ??return strname;
    ?}
    ?int getage()
    ?{
    ??return intage;
    ?}
    ?boolean getsex()
    ?{
    ??return blsex;
    ?}
    }
    ?//定義類的方法,
    ?//其結構如:返回數據類型 方法名稱(參數){具體實現方法的語句;}
    ?
    ?public class diaoyong
    ?{
    ??public static void main(String [] args)
    ??{
    ???Student astudent;
    ???astudent=new Student();
    ???
    ???astudent.init("董小莞",22,true);
    ???/*該語句和自定義類中的"void init(String name,int age,boolean sex)
    ?{
    ??strname=name;
    ??intage=age;
    ??blsex=sex;
    ?}"? 對應的,根據我的理解類中的方法是根據參數在main函數中取值,取值的順序一一對應,類型也是一一對應的,
    ?對象通過點符號,調用類中的方法,實現方法中的功能,看上去有模塊化的形狀,*/
    ???System.out.println("學生姓名是: "+astudent.getname());
    ???System.out.println("學生的性別是: "+astudent.getage());
    ???if(astudent.getsex())
    ???? System.out.println("性別是男");
    ???else
    ???? System.out.println("性別是女");
    ???}
    ??}
    ???
    posted @ 2006-10-15 10:44 悠揚---靖寶華 閱讀(463) | 評論 (1)編輯 收藏

    一條蛇長了兩只頭!
    把身子戳傷了,兩個腦袋都有痛感,


    如下:

    Student aStudent=new Student();
    Student bStudent=aStudent;

    第一句定義了一個變量,并且將一個對象的地址引用,
    就是說:變量aStudent,鏈接了一個新對象的地址,
    第二句:
    將變量aStudent,包含的地址,存放到bStudent去,
    這就相當于一個身子,長了兩個頭,
    其中的一個出現變化
    另一個肯定會受影響
    如圖所示,,
    對象引用1.bmp

    posted @ 2006-10-14 21:39 悠揚---靖寶華 閱讀(217) | 評論 (0)編輯 收藏

    /*class Student??????????????? //生成一個類
    {
    ?public String? strname;???? //定義類的屬性
    ?public int???? intage;????? //定義類的屬性
    ?public boolean blsex;?????? //定義類的屬性
    }


    public class twoStudentDemo??? //和文件名稱一定要形同!!否則編譯出錯.
    {
    ?public static void main(String [] args)
    ?{
    ??Student aStudent=new Student();? //由類定義一個具體的對象
    ?????
    ??
    ??aStudent.strname="董小飛";? ??//給對象屬性變量賦值
    ??aStudent.intage =22;?????????? //訪問對象的一個屬性變量,用"."運算符鏈接
    ??aStudent.blsex? =true;?????
    ??
    ??System.out.println("該學生的名字是: "+aStudent.strname);
    ??System.out.println("年齡是: "+aStudent.intage);
    ??if(aStudent.blsex)
    ?? System.out.println("性別是男");
    ??else
    ?? System.out.println("性別是女");
    ???
    ??Student bStudent=new Student();?
    ??bStudent.strname="董瀟瀟";? ??//給對象屬性變量賦值
    ??bStudent.intage =20;?????????? //訪問對象的一個屬性變量,用"."運算符鏈接
    ??bStudent.blsex? =false;?????
    ??
    ??System.out.println("該學生的名字是: "+bStudent.strname);
    ??System.out.println("年齡是: "+bStudent.intage);
    ??if(bStudent.blsex)
    ?? System.out.println("性別是男");
    ??else
    ?? System.out.println("性別是女");
    ??}
    ?}*/

    //將不同的對象理解為不同的內存空間,每個內存空間是相互無關的,不存在數據的覆蓋現象..

    posted @ 2006-10-14 20:38 悠揚---靖寶華 閱讀(795) | 評論 (0)編輯 收藏

    /*class Student??????????????? //生成一個類
    {
    ?public String? strname;???? //定義類的屬性
    ?public int???? intage;????? //定義類的屬性
    ?public boolean blsex;?????? //定義類的屬性
    }

    public class StudentDemo
    {
    ?public static void main(String [] args)
    ?{
    ??Student aStudent;????????? //由類定義一個具體的對象
    ??aStudent=new Student();???? //由類定義一個具體的對象
    ??
    ??aStudent.strname="董小飛";? ??//給對象屬性變量賦值
    ??aStudent.intage =22;?????????? //訪問對象的一個屬性變量,用"."運算符鏈接
    ??aStudent.blsex? =true;?????
    ??
    ??System.out.println("該學生的名字是: "+aStudent.strname);
    ??System.out.println("年齡是: "+aStudent.intage);
    ??if(aStudent.blsex)
    ?? System.out.println("性別是男");
    ??else
    ?? System.out.println("性別是女");
    ??}
    ?}*/


    1:由以上例題,本人發現:各種編程語言之間,"換臉不換心哪"!
    2:類就像是一個集合,而對象就像是集合中的一個元素!
    更正如下:::
    Student aStudent;????????? //由"Student類"定義一個變量,如同,"Sting 姓名";或者"int 年齡";因此在這個地方aStudent只是一個變量,
    ???aStudent=new Student();???? //這句中,new生成一個新的內存空間,我理解為"對象",并且將內存地址存放在aStudent變量中,

    posted @ 2006-10-14 19:57 悠揚---靖寶華 閱讀(440) | 評論 (4)編輯 收藏

    <2006年10月>
    24252627282930
    1234567
    891011121314
    15161718192021
    22232425262728
    2930311234

    常用鏈接

    留言簿(1)

    隨筆檔案(7)

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 30岁的女人韩剧免费观看| 亚洲精品视频免费观看| 综合一区自拍亚洲综合图区| 伊人婷婷综合缴情亚洲五月| 57pao国产成视频免费播放| 亚洲精品国产综合久久久久紧| 成人爱做日本视频免费| 黄 色一级 成 人网站免费| 久久狠狠爱亚洲综合影院| 波多野结衣中文一区二区免费 | 国产精品免费久久久久电影网| 亚洲男人天堂av| 性做久久久久免费观看| a级日本高清免费看| 亚洲6080yy久久无码产自国产| 亚洲三级电影网址| 四虎影视www四虎免费| 免费91麻豆精品国产自产在线观看 | 最近免费mv在线观看动漫| 久久国产亚洲精品| 亚洲AV综合色区无码一区| 国产美女精品久久久久久久免费| 国产在线观看免费视频软件| 亚洲AV无码一区二区一二区| 亚洲色图综合网站| 伊伊人成亚洲综合人网7777| 日本特黄特色免费大片| 亚洲一级毛片免费看| 青青操免费在线视频| 老牛精品亚洲成av人片| 亚洲ts人妖网站| 亚洲日本在线观看| 亚洲人成色77777| 国产免费av一区二区三区| 中文字幕无码不卡免费视频| 久久国产乱子伦精品免费看| 亚洲精品国产日韩无码AV永久免费网 | 亚洲精品亚洲人成人网| 亚洲五月午夜免费在线视频| 成人永久免费福利视频网站| 好男人视频社区精品免费|