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

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

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

    posts - 26,  comments - 14,  trackbacks - 0
     

    其實 很簡單:
    ==比較兩個數是否是同一對象即同一地址,而equals則比較兩個是否是同一個字符,或者是同一數值。。。。

    如果你還不明白,請看以下代碼:

    package Duixiang;

    public class First {
     
     
     public static void main(String args[]){
      
      
      String str1="abc";
      
      String str2=new String("abc");
      
         String str3=str2;
      System.out.println(str1==str2);//"=="比較兩個數是否是同一個對象,同一對象
      System.out.println(str2==str3);
      System.out.println(str1.equals(str2));//equals比較兩數是否是相同
      System.out.println(str2.equals(str3));
      System.out.println(str1.equals(str3));
      
      
     }

    }
    執行結果:
     

    posted @ 2010-11-06 22:51 龍ぜ殘劍 閱讀(127) | 評論 (0)編輯 收藏
    當今每一個小公司,還是大型企業都有一個人力資源管理部,然而他們的前臺的工作建面是基本都是基本是一樣。。。。就是人員的添加,修改,刪除而已。。。。。如下:
      
    再次選擇一個要操作的,比如在這里輸入:1  然后按照步驟執行結果為
     
      
    就此我就通過思考做了一下這個小程序,首先我分成了幾個類(1)平臺入口處(是一個main函數);(2)在執行main函數之后進入操作平臺,即menu菜單,(3)然后選擇你當前是要對員工是增加,更新,還是刪除工作(PersonOperate)來操作。。。。
    代碼如下:
    入口處代碼:

    package com.dr.demo.main;   

    import com.dr.demo.menu.Menu;

    public class Main {   
            public static void main(String[] args) {   
                    new Menu();   
            }   
    }
    進入平臺的程序:

    package com.dr.demo.menu;   

    import com.dr.demo.op.PersonOperate;
    import com.dr.demo.util.InputData;

    public class Menu {   
            InputData input = null;   
            public Menu(){   
                    this.input = new InputData();   
                    //循環出現菜單   
                    while(true){   
                         this.show();    //死循環
                  }   
            }   
            //需要定義的菜單內容   
            public void show(){   
                    System.out.println("\t\t\t1、增加人員信息");   
                    System.out.println("\t\t\t2、瀏覽人員信息");   
                    System.out.println("\t\t\t3、修改人員信息");   
                    System.out.println("\t\t\t4、退出人力資源系統。");   
                    System.out.print("\n\n請選擇要使用的操作:");   
                    int temp = input.getInt();   
                    switch(temp){   
                    case 1:{  // 增加人員信息
                            new PersonOperate().add(); //業務處理層  
                            break;   
                    }   
                    case 2:{ // 瀏覽人員信息 
                            new PersonOperate().show();   
                            break;   
                    }   
                    case 3:{ // 修改人員信息
                            new PersonOperate().update();   
                            break;   
                    }   
                    case 4:{ //退出系統
                            System.out.println("選擇的是退出系統");   
                            System.out.println("系統退出!");   
                            System.exit(1);   
                    }   
                    default:{   
                            System.out.println("輸入的內容不正確");   
                            break;   
                    }   
                    }   
            }   
    }
    然后是PersonOperate類對的每個對象的增刪改操作:

    package com.dr.demo.op;   

    import com.dr.demo.util.FileOperate;
    import com.dr.demo.util.InputData;
    import com.dr.demo.vo.Person;

    public class PersonOperate {   
            private InputData input = null;   
            public PersonOperate(){   
                    this.input = new InputData();   
            }   
            //完成具體的Person對象操作   
            public void add(){   
                    //要使用輸入數據的類   
                    String name = null;   
                    int age = 0;   
                    float score = 0.0f;   
                    System.out.print("輸入姓名:");   
                    name = this.input.getString();   
                    System.out.print("輸入年齡:");   
                    age = this.input.getInt();   
                    System.out.print("輸入成績:");   
                    score = this.input.getFloat();   
                    //生成Person對象,把對象保存在文件中   
                    Person p = new Person(name,age,score);   
                              
                    try{   
                            new FileOperate().save(p);    //io操作層
                            System.out.println("數據保存成功!");   
                    }catch(Exception e){   
                            System.out.println("數據保存失敗!");   
                    }   
            }   
            public void show(){   
                    //從文件中把內容讀進來   
                    Person p = null;   
                    try{   
                            p = (Person) new FileOperate().read();   
                    }catch(Exception e){   
                            System.out.println("內容顯示失敗,請確定數據是否存在!");   
                    }   
                    if(p != null){   
                            System.out.println(p);   
                    }   
            }   
            public void update(){   
                    //先將之前的信息查出來   
                    Person p = null;   
                    try{   
                            p = (Person) new FileOperate().read();   
                    }catch(Exception e){   
                            System.out.println("內容顯示失敗,請確定數據是否存在!");   
                    }   
                    if(p != null){   
                            String name = null;   
                            int age = 0;   
                            float score =0.0f;   
                            System.out.print("請輸入新的姓名(原姓名:"+p.getName()+")");   
                            name = this.input.getString();   
                            System.out.print("請輸入新的年齡(原年齡:"+p.getAge()+")");   
                            age = this.input.getInt();   
                            System.out.print("請輸入新的成績(原成績:"+p.getScore()+")");   
                            score = this.input.getFloat();   
                            //信息重新設置   
                            p.setName(name);   
                            p.setAge(age);   
                            p.setScore(score);   
                            try{   
                                    new FileOperate().save(p);   
                                    System.out.println("數據更新成功!");   
                            }catch(Exception e){   
                                    System.out.println("數據更新失敗!");   
                            }   
                    }   
            }   
    }

     

    posted @ 2010-11-06 21:55 龍ぜ殘劍 閱讀(151) | 評論 (0)編輯 收藏

    現在很多醫院都在實行掛號制度,有利于維持醫院的次序。起初感覺是很難開發的一個系統,其實不然,仔細想起來不是 一件什么難事。。。嘿嘿,我是這樣來實現著個項目的。。。。分析如下,把醫院系統簡單地分成幾種類,病人,醫生,掛號等等。。

    第一:掛號選擇醫生
    代碼如下:

    package Waiter;

    import java.util.Queue;

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Font;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

     

    public class HospitalWorkerUi {
     public static void main(String args[]){
        
     final Display display= Display.getDefault();
     final Shell shell = new Shell();
     shell.setMaximized(true);
     shell.setText("醫院工作人員");
     
     QueueServer qs = new QueueServer();
     final Queue<Waiter> waiterList = qs.init();
     final Queue<SoWaiter> soWaiterList = qs.init1();
     final Queue<FastWaiter> FastWaiterList = qs.init2();
     
     final Text txt = new Text(shell,SWT.MULTI);
        txt.setBounds(500, 50, 550, 450);
     // 事件代碼里要訪問button
     final Button button = new Button(shell, SWT.Activate);
     button.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
        public void widgetSelected(SelectionEvent e) {
         //System.out.println("############### " + waiterList.size());
         Waiter waiter= waiterList.poll();
         if(waiter!= null){
           txt.setText(waiter.getNum()+"號顧客請到1號窗口檢查");
         }else{
          txt.setText("現在沒有人,您可以休息會了\n 喝杯咖啡吧,哈哈!");
         }
        }
       });//數據庫存取,網絡連接,邏輯處理
     button.setBounds(450, 530, 200,75); // 設置按鈕位置
     button.setFont(new Font(display,"宋體",12,SWT.BOLD));
     button.setText("專家 張醫生");// 設置按鈕上的文字
     
     final Button button1 = new Button(shell, SWT.Activate);
     button1.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
        public void widgetSelected(SelectionEvent e) {
         //System.out.println("############### " + waiterList.size());
         SoWaiter waiter= soWaiterList.poll();
         if(waiter!= null){
           txt.setText(waiter.getNum()+"號顧客請到2號窗口檢查");
         }else{
          txt.setText("現在沒有人,您可以休息會了\n 喝杯咖啡吧,哈哈!");
         }
        }
       });//數據庫存取,網絡連接,邏輯處理
     button1.setBounds(750, 530, 200,75); // 設置按鈕位置
     button1.setFont(new Font(display,"宋體",12,SWT.BOLD));
     button1.setText("專家  王醫生");// 設置按鈕上的文字
     
     final Button button2 = new Button(shell, SWT.Activate);
     button2.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
        public void widgetSelected(SelectionEvent e) {
         //System.out.println("############### " + waiterList.size());
         FastWaiter waiter= FastWaiterList.poll();
         if(waiter!= null){
           txt.setText(waiter.getNum()+"號顧客請到3號窗口檢查");
         }else{
          txt.setText("現在沒有人,您可以休息會了\n 喝杯咖啡吧,哈哈!");
         }
        }
       });//數據庫存取,網絡連接,邏輯處理
     button2.setBounds(1050, 530, 200,75); // 設置按鈕位置
     button2.setFont(new Font(display,"宋體",12,SWT.BOLD));
     button2.setText("專家  李醫生");// 設置按鈕上的文字

     
     shell.layout();
     shell.open();
     while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
       display.sleep();
    }
    }
    }
    運行結果:
     
    第二:醫生按次序為病人治病
    實現代碼如下:

    package Waiter;

    import java.util.Queue;

    import org.eclipse.swt.SWT;
    import org.eclipse.swt.events.SelectionAdapter;
    import org.eclipse.swt.events.SelectionEvent;
    import org.eclipse.swt.graphics.Font;
    import org.eclipse.swt.widgets.Button;
    import org.eclipse.swt.widgets.Display;
    import org.eclipse.swt.widgets.Label;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Text;

     

    public class WaiterQueueUi {
     public static void main(String args[]){
      final Display display=Display.getDefault();
      final Shell shell=new Shell();
      shell.setMaximized(true);
      shell.setText("醫院病人掛號口");
      
      QueueServer qs = new QueueServer();//實例化類
      QueueServer q= new QueueServer();
      QueueServer p = new QueueServer();
      
         final Queue<Waiter> waiterList = qs.init();//初始化隊列服務器
         final Text txt = new Text(shell,SWT.MULTI);
         txt.setBounds(65, 30, 180, 70);
         final Queue<SoWaiter> soWaiterList = q.init1();
         final Text txt1 = new Text(shell,SWT.MULTI);
         txt1.setBounds(400, 30, 180, 70);
         final Queue<FastWaiter> fastWaiterList = p.init2();
         final Text txt2 = new Text(shell,SWT.MULTI);
         txt2.setBounds(800, 30, 180, 70);
        
        
         Label label=new Label(shell,SWT.NULL);
         label.setBounds(400, 250, 500, 205); // 設置按鈕位置
         label.setFont(new Font(display,"宋體",16,SWT.BOLD));
      label.setText("醫院會為您們最優質的服務!!!");// 設置按鈕上的文字
        
      // 事件代碼里要訪問button
      final Button button = new Button(shell, SWT.Activate);
      button.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
         public void widgetSelected(SelectionEvent e) {
          //System.out.println("############### " + waiterList.size());
          Waiter waiter= waiterList.poll();
          if(waiter!= null){
            txt.setText(waiter.getNum()+"號顧客請到1號窗口辦理業務");
          }else{
           txt.setText("現在沒有人辦理業務了,您可以休息會了\n 喝杯咖啡吧,哈哈!");
          }
         }
        });//數據庫存取,網絡連接,邏輯處理
      button.setBounds(90, 141, 100, 25); // 設置按鈕位置
      button.setText("專家 張醫生");// 設置按鈕上的文字
      
      
      
      
      
        
      // 事件代碼里要訪問button
      final Button button1 = new Button(shell, SWT.Activate);
      button1.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
         public void widgetSelected(SelectionEvent e) {
          //System.out.println("############### " + waiterList.size());
          SoWaiter sowaiter= soWaiterList.poll();
          if(sowaiter!= null){
            txt1.setText(sowaiter.getNum()+"病人到2號門診辦理業務"+"\n"+"二號門診專家會認真給你檢查病情的");
          }else{
           txt1.setText("現在沒有人辦理業務了,您可以休息會了\n 喝杯咖啡吧,哈哈!");
          }
         }
        });//數據庫存取,網絡連接,邏輯處理
      button1.setBounds(450, 141, 100, 25); // 設置按鈕位置
      button1.setText("專家  王醫生");// 設置按鈕上的文字
      
      
      
        
      // 事件代碼里要訪問button
      final Button button2 = new Button(shell, SWT.Activate);
      button2.addSelectionListener(new SelectionAdapter() { // 加一個??擇監聽器
         public void widgetSelected(SelectionEvent e) {
          //System.out.println("############### " + waiterList.size());
          FastWaiter fastWaiter= fastWaiterList.poll();
          if(fastWaiter!= null){
            txt2.setText(fastWaiter.getNum()+"號顧客請到1號窗口辦理業務");
          }else{
           txt2.setText("現在沒有人辦理業務了,您可以休息會了\n 喝杯咖啡吧,哈哈!");
          }
         }
        });//數據庫存取,網絡連接,邏輯處理
      button2.setBounds(800, 141, 100, 25); // 設置按鈕位置
      button2.setText("專家  李醫生");// 設置按鈕上的文字
      
      
      
      
      shell.layout();
      shell.open();
      while (!shell.isDisposed()) {
       if (!display.readAndDispatch())
        display.sleep();
      
     }

    }
    }

    執行結果如下:
     

    posted @ 2010-11-04 11:00 龍ぜ殘劍 閱讀(1311) | 評論 (0)編輯 收藏

    開始想做的時候感覺很簡單,動手做起來其實不是那么的簡單呢。這里以文件 f:\\Dato.txt為例
    首先使用File查找是否存在文件f:\\Dato.txt,文件存在就把里面的內容修改掉。。。。

    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.OutputStream;

    public class IO {

      public static void main(String[] args) {
      // TODO Auto-generated method stub
            File f=null;
                  f=new File("f:\\Dato.txt");//使用File找到文件,并且在之內寫入文件。。。。。
           if(f.exists()){
               //如果為真則表示文件存在
               //如果存在則刪除文件
               f.delete();
            }else{
           try{
            System.out.println(f.createNewFile());
           }catch(Exception e){}
         //在文件中寫入文件則要用------outputStream 
          
           OutputStream out=null;
           //需要用子類進行實例化
           try{
            out= new FileOutputStream(f);
           }catch(Exception e){}
           //現在向其中寫入 數據
           String str="歡迎來到JAVA世界!!!........";
           byte b[]=str.getBytes();
           //向文件中寫入內容
           try{
            out.write(b);
           }catch(Exception e){}
           //關閉文件
           try{
            out.close();
           }catch(Exception e){}
           
         }
      }

    }

    posted @ 2010-11-02 12:37 龍ぜ殘劍 閱讀(154) | 評論 (0)編輯 收藏



    IO 流的作用:是能夠從發送字節序列的數據源獲取數據,以及如何將數據發送到能夠接收字節流的任何目的地,也就是輸入和輸出。。字節序列的源和目的地可以是文件,網絡連接,內存塊等,不管在文件中的信息還是網絡連接的信息他們的接收在本質上是一樣的。

      
    這里有一個小程序:

    import java.io.*;


    public class IO{
    public static void main(String args[]){
    File a = null; //  判斷是否存在文件 a;
    File a=new File("f:\\James\\wto.txt"); //新建文件a
    try{
    System.out.println(f.createNewFile());//打印是否創建成功
    }catch(Exception e){}
    }

    如果打印的是ture,文件創建成功。打印false表明抽象地址中已經存該在文件,不用再創建。。
    posted @ 2010-11-02 09:39 龍ぜ殘劍 閱讀(119) | 評論 (0)編輯 收藏


    class People1{
      public String sex;
      public int age;
      public void say(){
       System.out.println("小黑:"+sex+"  年齡:"+age);
      }
     }


    public class People {
     public static void main(String[] args) throws InterruptedException {
        People1 p1 =new People1();        //里面先new了兩個對象,分別問p1和p2
        People1 p2 =new People1();
        p1=p2;               //p1.p2指向同一地址p2.
        p1.sex="雄性";
        p1.age=6;
        p1.say();
        p2.sex="雌性";
        p2.age=12;
        p2.say();

     }

    }

    運行結果:
      

    例子先new了兩個對象,分別問p1和p2,然后將p2的值附給了p1,這時,p1的指向就發生了變化:p1就不再指向原來的地址了,此時p1就指向了p2所指向的地址了,也就是說:p1和p2指向了同一塊堆內存。這時先給p1的屬性賦值,并且調用了p1的say方法,這個時候控制臺就打印出來p1所指向的堆地址(實際此時p2指向的也是這個堆地址);然后又給p2的屬性賦值,并且調用了p2的say方法,這個時候控制臺就會打印出來p2所指向的堆地址(實際此時p1指向的也是這個堆地址),兩次打印出來的字符串是不一樣的,因為數值發生了改變。
    posted @ 2010-10-31 22:48 龍ぜ殘劍 閱讀(118) | 評論 (0)編輯 收藏
    僅列出標題
    共3頁: 上一頁 1 2 3 
    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    留言簿

    隨筆檔案

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 久久精品成人免费观看97| 亚洲一卡2卡三卡4卡无卡下载| 黄页网址在线免费观看| 国产三级免费电影| 免费人成大片在线观看播放| 亚洲综合视频在线观看| 无码国产精品一区二区免费16| 亚洲动漫精品无码av天堂| A级毛片高清免费视频在线播放| 亚洲国产精品SSS在线观看AV| 人人玩人人添人人澡免费| 久久久久亚洲精品影视| 1000部拍拍拍18勿入免费凤凰福利| 亚洲精品福利在线观看| 成年免费大片黄在线观看岛国| 中文字幕亚洲码在线| 免费国内精品久久久久影院| 国产vA免费精品高清在线观看| 亚洲最大AV网站在线观看| 久久久久久成人毛片免费看| 亚洲大尺码专区影院| 日本无卡码免费一区二区三区| 老湿机一区午夜精品免费福利| 亚洲国产综合久久天堂| 中文字幕无码一区二区免费| 亚洲欧洲国产视频| 成人免费无码大片a毛片软件| 国产成人va亚洲电影| 亚洲中文字幕无码不卡电影| 69视频在线是免费观看| 亚洲精品国产高清在线观看| 国产精品亚洲综合一区| 99国产精品视频免费观看| 精品亚洲456在线播放| 亚洲精品成人区在线观看| 久久精品成人免费观看| 亚洲乱色伦图片区小说 | 免费污视频在线观看| 亚洲午夜精品一区二区公牛电影院| 国产裸模视频免费区无码| 日韩精品免费视频|