hes_daydreaming吧 关注:32贴子:739

回复:手编类代码集 = - 见证咱的进步吧

只看楼主收藏回复

因为在工作中的class基本都没有覆盖默认的无参数构造方法,所以这个地方理解错了,sorry啊


IP属地:四川62楼2010-07-16 10:33
回复
    = - 恩 书上是说 不写的话 默认调用父类的无参构造器 如果没有无参构造器就会报错。。。


    63楼2010-07-16 10:34
    回复
      回复:62楼
      呵呵 没什么关系 你是我师傅~~~能帮我我已经很感谢了!


      64楼2010-07-16 10:35
      回复
        回复:64楼
        不是师傅,互相交流


        IP属地:四川65楼2010-07-16 10:35
        回复
          好的好的 以后还有很多问题要问呢!


          66楼2010-07-16 10:36
          回复
            package a;
            import java.awt.*;
            import java.awt.event.*;
            import javax.swing.*;
            public class Cat{
                 private static void creatAndShowGUI(){
                     JFrame frame = new JFrame("Fcuk!");
                     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     JMenuBar greenMenuBar = new JMenuBar();
                     greenMenuBar.setOpaque(true);
                     greenMenuBar.setBackground(new Color(248,165,127));
                     greenMenuBar.setPreferredSize(new Dimension(200,20));
                     JLabel yellowLable = new JLabel();
                     yellowLable.setOpaque(true);
                     yellowLable.setBackground(new Color(248,213,131));
                     yellowLable.setPreferredSize(new Dimension(200,180));
                     frame.setJMenuBar(greenMenuBar);
                     frame.getContentPane().add(yellowLable,BorderLayout.CENTER);
                     frame.pack();
                     frame.setVisible(true);
                    
                 }
                 public static void main(String [] args){
                     javax.swing.SwingUtilities.invokeLater(new Runnable(){
                         public void run(){
                             creatAndShowGUI();
                        
                         }
                     });
                    
                 }
            }


            67楼2010-08-06 09:08
            回复
              回复:67楼
              没有注释,没有美感啊


              68楼2010-08-17 14:54
              回复
                import java.io.FileInputStream;
                import java.io.FileNotFoundException;
                import java.io.FileOutputStream;
                import java.io.IOException;
                public class Test {
                     public static void main(String []args){
                         int count,n=512;
                         byte [] buffer = new byte [n];
                         try {
                             System.out.print("输入文字!");
                             count = System.in.read(buffer);
                             FileOutputStream os = new FileOutputStream("a.txt");
                             os.write(buffer,0,count);
                             os.close();
                             System.out.print("保存成功!");
                         } catch (IOException e) {
                             // TODO 自动生成 catch 块
                             e.printStackTrace();
                         }
                         try {
                             FileInputStream ak = new FileInputStream("a.txt");
                             while((ak.read(buffer,0,n)!=-1 )&& n >0);
                             {
                                 System.out.print(new String(buffer));
                             }
                             System.out.println();
                             ak.close();
                         } catch (FileNotFoundException e) {
                             // TODO 自动生成 catch 块
                             e.printStackTrace();
                         } catch (IOException e) {
                             // TODO 自动生成 catch 块
                             e.printStackTrace();
                         }
                            
                        
                     }
                }
                IO字节流练习


                69楼2010-09-18 12:35
                回复
                  public class Test implements Runnable {
                       public Test(){
                          
                       }
                       public void run(){
                       int a = 0;
                       for(a = 0;a<100;a++){
                           try {
                               Thread.sleep(1000);
                               System.out.print(a);
                               System.out.println();
                           } catch (InterruptedException e) {
                               // TODO 自动生成 catch 块
                               System.out.print("被打扰,终止!");
                              
                           }
                          
                       }
                       }
                      
                      
                  }
                  public class RunDemo {
                       public static void main (String [] args) throws InterruptedException{
                           System.out.print("线程启动中……");
                           Thread t = new Thread(new Test());
                           t.start();
                           System.out.print("waiting....");
                           System.out.println();
                           while(t.isAlive()){
                               System.out.print("still alive....");
                               System.out.println();
                               t.join(1000);
                           }
                          
                       }
                  }
                  


                  70楼2010-09-20 09:19
                  回复